1 #include<stdio.h> 2 int main(){ 3 int i,j,n; 4 int a[13][13]; 5 do{ 6 printf("Enter n(1—12):"); 7 scanf("%d",&n); 8 }while(!(n>=1&&n<=12)); 9 for(i=0;i<=n;i++){ 10 a[i][0]=1; 11 a[i][i]=1; 12 for(j=1;j<=i-1;j++) 13 a[i][j]=a[i-1][j-1]+a[i-1][j]; 14 for(j=1;j<=37-3*i;j++) 15 printf(" "); 16 for(j=0;j<=i;j++) 17 printf("%6d",a[i][j]); 18 printf("\n\n"); 19 } 20 return 0; 21 }
原文地址:https://www.cnblogs.com/geziyu/p/8783434.html
时间: 2024-10-03 08:31:40