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

avatar iaaaia
@iaaaia

2 Kontribusi 0 Poin

Diperbarui 2 tahun yang lalu

4 Jawaban:

<div>logicnya sih setiap loop maka gambar/tandai +1 di horizontal dan +1 di vertical</div>

avatar hilmanski
@hilmanski

2686 Kontribusi 2135 Poin

Dipost 2 tahun yang lalu

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="{&quot;contentType&quot;:&quot;image/png&quot;,&quot;filename&quot;:&quot;image.png&quot;,&quot;filesize&quot;:70519,&quot;height&quot;:791,&quot;url&quot;:&quot;https://i.ibb.co/JdVHhxB/image.png&quot;,&quot;width&quot;:813}" data-trix-content-type="image/png" data-trix-attributes="{&quot;presentation&quot;:&quot;gallery&quot;}" 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="{&quot;contentType&quot;:&quot;image/png&quot;,&quot;filename&quot;:&quot;image.png&quot;,&quot;filesize&quot;:4957,&quot;height&quot;:530,&quot;url&quot;:&quot;https://i.ibb.co/rtgZfPB/image.png&quot;,&quot;width&quot;:203}" data-trix-content-type="image/png" data-trix-attributes="{&quot;presentation&quot;:&quot;gallery&quot;}" 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>

avatar iaaaia
@iaaaia

2 Kontribusi 0 Poin

Dipost 2 tahun yang lalu

<div>coba pelajari code dibawah<br><figure data-trix-attachment="{&quot;contentType&quot;:&quot;image/png&quot;,&quot;filename&quot;:&quot;sk_iaaaia_staircase.png&quot;,&quot;filesize&quot;:919429,&quot;height&quot;:2752,&quot;url&quot;:&quot;https://i.ibb.co/Wv989XC/sk-iaaaia-staircase.png&quot;,&quot;width&quot;:3960}" data-trix-content-type="image/png" data-trix-attributes="{&quot;presentation&quot;:&quot;gallery&quot;}" 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="{&quot;contentType&quot;:&quot;image/png&quot;,&quot;filename&quot;:&quot;sk_iaaaia_staircase_v3.png&quot;,&quot;filesize&quot;:435572,&quot;height&quot;:1664,&quot;url&quot;:&quot;https://i.ibb.co/gykw1xW/sk-iaaaia-staircase-v3.png&quot;,&quot;width&quot;:2792}" data-trix-content-type="image/png" data-trix-attributes="{&quot;presentation&quot;:&quot;gallery&quot;}" 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>

avatar soeleman
@soeleman

120 Kontribusi 147 Poin

Dipost 2 tahun yang lalu

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 &lt; 5; i++){ for(var j = 0; j &lt; i; j++){ console.log("-"); }

    for(var j = 0; j &amp;lt; i; j++){
        console.log(&quot;#&quot;);
    }
    
    for(var j = 0; j &amp;lt; i; j++){
        console.log(&quot;\n&quot;);
    }
    
}

}</pre>

avatar hilmanski
@hilmanski

2686 Kontribusi 2135 Poin

Dipost 2 tahun yang lalu

Login untuk ikut Jawaban