Problem : 2032 ( 杨辉三角 ) Judge Status : Accepted
RunId : 6013310 Language : C Author : qq1203456195
Code Render Status : Rendered By HDOJ C Code Render Version 0.01 Beta
RunId : 6013310 Language : C Author : qq1203456195
Code Render Status : Rendered By HDOJ C Code Render Version 0.01 Beta
1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <string.h> 4 int arr[31][31]; 5 void init() 6 { 7 int i,j; 8 memset(arr,0,sizeof(arr)); 9 arr[0][0]=1; 10 for (i=1;i<30;i++) 11 { 12 for (j=i;j>=0;j--) arr[i][j]=arr[i-1][j]+arr[i-1][j-1]; 13 } 14 } 15 int main() 16 { 17 int n,i,j; 18 init(); 19 while (scanf("%d",&n)!=EOF) 20 { 21 for (i=0;i<n;i++) 22 { 23 printf("%d",arr[i][0]); 24 for (j=1;j<=i;j++) printf(" %d",arr[i][j]); 25 printf("\n"); 26 } 27 printf("\n"); 28 } 29 return 0; 30 }