Sabtu, 05 November 2011

Membuat Segitiga Bintang / Segitiga Pascal [Java]

Source Code :

public class Segitiga2{
    public static void main(String[]args){
        int n=15;
        int a,b;
        String tampil = "";
        for(int i=1;i<=n;i+=2){
            for(a=n;a>i;a--){
                tampil +=" ";
            }
            for (b=1;b<=i;b++){
                tampil +="* ";
            }
            tampil +="\n";
        }
        System.out.print(tampil);
    }
}




Output :


Source Code :


public class SegitigaSiku{
    public static void main(String[]args){
        int n=15;
        int a;
        String tampil = "";
        for(int i=1;i<=n;i++){
            for(a=1;a<=i;a++){
                tampil +="* ";
            }
            tampil +="\n";
        }
        System.out.print(tampil);
    }
}


Output :

Posting Baru Posting Lama Beranda

1 komentar:

Unknown mengatakan...

order segitiga bolong dong ..

Posting Komentar

 
Design by Wordpress Theme | Bloggerized by Free Blogger Templates | coupon codes