~Setengah Piramida Kiri
import javax.swing.*;
public class Main {
public static void main (String[]args) {
int angka=Integer.valueOf(JOptionPane.showInputDialog("Masukkan Angka"));
for (int i=1;i<=angka;i++ ) {
for (int j=angka;j>i;j--) {
System.out.print(" ");
}
for (int k=1;k<=i;k++ ) {
System.out.print("*");
}
System.out.println( );
}
}
}
Output :
*
* *
* * *
* * * *
* * * * *
Tidak ada komentar:
Posting Komentar