hdu2032

http://acm.hdu.edu.cn/showproblem.php?pid=2032

 1 #include<stdio.h>
 2 #include<math.h>
 3 #include<string.h>
 4 #include<stdlib.h>
 5 #include<iostream>
 6 using namespace std;
 7 
 8 
 9 int main()
10 {
11     //freopen("in.txt","r",stdin);
12     int n;
13     int a[40][40];
14     memset(a,0,sizeof(a));
15     a[1][1]=1;
16     a[2][1]=1;
17     a[2][2]=1;
18     for(int i=1;i<=30;i++)
19     a[i][1]=1;
20     for(int i=3;i<=30;i++)
21     {
22         for(int j=2;j<=30;j++)
23         {
24             a[i][j]=a[i-1][j-1]+a[i-1][j];
25         }
26     }
27     while(~scanf("%d",&n))
28     {
29         for(int i=1;i<=n;i++)
30         {
31             for(int j=1;j<=n;j++)
32             {
33                 if(a[i][j]==0)
34                 continue;
35                 if(j==1)
36                 printf("%d",a[i][j]);
37                 else
38                 printf(" %d",a[i][j]);
39             }
40             printf("
");
41         }
42         cout<<endl;
43     }
44     return 0;
45 }
原文地址:https://www.cnblogs.com/xuesen1995/p/4939759.html