.: Java :. Membuat Segitiga siku-siku

package Bentuk;

import javax.swing.JOptionPane;

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author Nurul C.
*/
public class segitiga_sikuSiku {
public static void main(String[] args) {
int n, m, angka;
angka = Integer.parseInt(JOptionPane.showInputDialog(“Masukkan deret siku-sikunya!!”));
for (n=1;n<=angka;n++){
for (m=angka;m>=2;m–){
System.out.print(” “);
}
for (m=1;m<=n;m++){
System.out.print(n+” “);
}
System.out.print(“\n”);
}
}
}

Berikut hasil outputnya :

array

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Logout / Ubah )

Twitter picture

You are commenting using your Twitter account. Logout / Ubah )

Facebook photo

You are commenting using your Facebook account. Logout / Ubah )

Google+ photo

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s