Minggu, 05 Desember 2010

Membuat Piramida Terbalik Penuh Pada JAVA


~ Piramida Terbalik Full
import javax.swing.*;
public class Main {
    public static void main (String args[]){
        int a,b,c;
        int v=Integer.valueOf(JOptionPane.showInputDialog("Masukan Angka"));
            for(a=1;a<=v;a++){
            for(b=1;b<=a;b++){
            System.out.print(" ");
            }
            for(c=0;c>=(a-v);c--)
            {
            System.out.print("*");
            }
            for(c=0;c<(v-a);c++){
            System.out.print("*");
            }
            System.out.println("");
        }
    }
}
Output :
* * * * * * * * *
* * * * * * *
* * * * *
* * *
 *

1 komentar: