1 #include<stdio.h> 2 #include <windows.h> 3 #define N 10 4 int main() 5 { 6 int a[N][N] = { 0 }; 7 for (int i = 0; i < N; i++) 8 { 9 for (int j = 0; j < N; j++) 10 { 11 if (i==j||j==0) 12 { 13 a[i][j] = 1; 14 } 15 else { 16 a[i][j] = a[i - 1][j - 1] + a[i - 1][j]; 17 } 18 } 19 } 20 21 for (int i = 0; i < N;i++) 22 { 23 for (int j = 0; j <= i; j++) 24 { 25 printf("%4d", a[i][j]); 26 27 } 28 printf(" "); 29 } 30 31 for (int i = 0; i < N; i++) 32 { 33 printf("%*d", 30 -2* i, a[i][0]); 34 for (int j = 1; j <= i; j++) 35 { 36 printf("%4d", a[i][j]); 37 38 } 39 printf(" "); 40 } 41 42 43 system("pause"); 44 }