Postingan lainnya
Staircase Pattern Java
Help logic untuk pattern ini gimana untuk yang automate script nya di java?Screenshot_2022-07-01-12-17-54-704_app.cicle.jpg
Udah seminggu mikir gadapet. makasih bantuannya
4 Jawaban:
<div>logicnya sih setiap loop maka gambar/tandai +1 di horizontal dan +1 di vertical</div>
Tanggapan
hi kak saya masih butuh bantuan koreksi, mohon bantuannya, terima kasih @hilmanski
<div>hi kak terima kasih responnya,</div><div class="attachment-gallery attachment-gallery--2"><figure data-trix-attachment="{"contentType":"image/png","filename":"image.png","filesize":70519,"height":791,"url":"https://i.ibb.co/JdVHhxB/image.png","width":813}" data-trix-content-type="image/png" data-trix-attributes="{"presentation":"gallery"}" class="attachment attachment--preview attachment--png"><img src="https://i.ibb.co/JdVHhxB/image.png" width="813" height="791"><figcaption class="attachment__caption"><span class="attachment__name">image.png</span></figcaption></figure><figure data-trix-attachment="{"contentType":"image/png","filename":"image.png","filesize":4957,"height":530,"url":"https://i.ibb.co/rtgZfPB/image.png","width":203}" data-trix-content-type="image/png" data-trix-attributes="{"presentation":"gallery"}" class="attachment attachment--preview attachment--png"><img src="https://i.ibb.co/rtgZfPB/image.png" width="203" height="530"><figcaption class="attachment__caption"><span class="attachment__name">image.png</span></figcaption></figure></div><div>saya udah script yang saya pakai sudah seperti yang kakak sarankan, tapi hasilnya masih belum sesuai. kira-kira apa yang belum tepat ya kak?<br>@hilmanski</div>
<div>coba pelajari code dibawah<br><figure data-trix-attachment="{"contentType":"image/png","filename":"sk_iaaaia_staircase.png","filesize":919429,"height":2752,"url":"https://i.ibb.co/Wv989XC/sk-iaaaia-staircase.png","width":3960}" data-trix-content-type="image/png" data-trix-attributes="{"presentation":"gallery"}" class="attachment attachment--preview attachment--png"><img src="https://i.ibb.co/Wv989XC/sk-iaaaia-staircase.png" width="3960" height="2752"><figcaption class="attachment__caption"><span class="attachment__name">sk_iaaaia_staircase.png</span></figcaption></figure><br>saya berharap anda bisa mempelajari logika-nya dari code diatas (ada banyak cara, tapi logic-nya sama).<br><figure data-trix-attachment="{"contentType":"image/png","filename":"sk_iaaaia_staircase_v3.png","filesize":435572,"height":1664,"url":"https://i.ibb.co/gykw1xW/sk-iaaaia-staircase-v3.png","width":2792}" data-trix-content-type="image/png" data-trix-attributes="{"presentation":"gallery"}" class="attachment attachment--preview attachment--png"><img src="https://i.ibb.co/gykw1xW/sk-iaaaia-staircase-v3.png" width="2792" height="1664"><figcaption class="attachment__caption"><span class="attachment__name">sk_iaaaia_staircase_v3.png</span></figcaption></figure></div>
Tanggapan
hi kak kalo pakai codingan sederhana sebatas if dan looping gimana? seperti codingan saya di atas. kakak ada masukan?
<div>Bukan efisien, tapi kurang lebih mungkin logicnya begini (versi javascript)</div><pre>function drawStairCase(){ //each loop add "-" in horizontal, and add break on vertical for(var i = 0; i < 5; i++){ for(var j = 0; j < i; j++){ console.log("-"); }
for(var j = 0; j &lt; i; j++){
console.log("#");
}
for(var j = 0; j &lt; i; j++){
console.log("\n");
}
}
}</pre>