ads- class Test
- {
- public static void main(String[] ss){
- print(6);
- }
- public static void print(int n)
- {
- int[][] a = new int[n][n];
- for(int i=0;i<n;i++){
- a[i][0] = 1;
- a[i][i] = 1;
- }
- for(int i=2;i<n;i++)
- {
- for(int j=1;j<n-1;j++)
- a[i][j] = a[i-1][j] + a[i-1][j-1];
- }
- for(int i=0;i<n;i++)
- {
- for(int j=0;j<i+1;j++)
- System.out.print(a[i][j]+" ");
- System.out.println();
- }
- }
- }
复制代码
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1 |
|