Syafi'i Blog's'

Kamis, 30 Juli 2009

Segitiga Pascal

/**
* @(#)SegitigaPascal.java
*
*
* @author syafii jauhari
* @version 1.00 2009/7/27
*/


public class SegitigaPascal
{
private static void hitung ()
{

int sgtg[][] = new int[15][];

for (int r=0; r {
sgtg[r] = new int[r+1];
sgtg[r][0] = 1;
sgtg[r][r] = 1;
for (int c=1; c {
sgtg[r][c] = sgtg[r-1][c]+sgtg[r-1][c-1];
}
}
for (int r=0; r {
for (int c=0; c {
System.out.print(" "+sgtg[r][c]);
}
System.out.println("");
}

}
public static void main(String [] args)
{
hitung();
}
}










0 komentar:

Template by : auraipank x-template.blogspot.com