Треугольник Паскаля
Листинг 1.6. Треугольник Паскаля
class PascalTriangle{
public static final int LINES = 10; // Так определяются констан
public static void main(String[] args) {
int[][] p, = new int [LINES] [];
p[0] = new int[1];
System, out. println (p [0] [0] = 1);
p[l] = new int[2];
p[l][0] = p[l][1] = 1;
System.out.println(p[1][0] + " " + p[l][l]);
for (int i = 2; i < LINES; i++){
p[i] = new int[i+l];
System.out.print((p[i][0] = 1) + " ");
for (int j = 1; j < i; j++)
System.out. print ( (p[i] [j] =p[i-l][j-l] -bp[i-l][j]) + " ");
System, out. println (p [ i] [i] = 1)
}
}
}