1 #include<stdio.h>
2 #include<stdlib.h>
3 #include<string.h>
4 int main()
5 {
6 int ret[50][50],i,j,n;
7 ret[1][1]=ret[2][1]=ret[2][2]=1;
8 for(i=3;i<=30;i++)
9 {
10 for(j=2;j<=i-1;j++)
11 {
12 ret[i][j]=ret[i-1][j-1]+ret[i-1][j];
13 }
14 ret[i][1]=ret[i][i]=1;
15 }
16 while(scanf("%d",&n)==1)
17 {
18 for(i=1;i<=n;i++)
19 {
20 for(j=1;j<=i;j++)
21 {
22 if(j>1)
23 printf(" ");
24 printf("%d",ret[i][j]);
25 }
26 printf("\n");
27 }
28 printf("\n");
29 }
30 return 0;
31 }
1 # include <stdio.h>
2
3
4 int tri[35][35] ;
5
6
7 void output (int n)
8 {
9 int i, j ;
10 for (i = 0 ; i < n ; i++)
11 {
12 for (j = 0 ; j < i+1 ; j++)
13 if (j == 0) printf ("%d", tri[i][j] ) ;
14 else printf (" %d", tri[i][j]) ;
15 puts ("" );
16 }
17 puts ("" ) ;
18 }
19
20 int main ()
21 {
22 int i, j, n ;
23 for (i = 0 ; i < 30 ; i++)
24 tri[i][0] = 1 ;
25 for (i = 1 ; i < 30 ; i++)
26 for (j = 1 ; j <= i ; j++)
27 tri[i][j] = tri[i-1][j] + tri[i-1][j-1] ;
28 while (~scanf ("%d", &n))
29 output (n) ;
30
31 return 0 ;
32 }
1 #include<iostream>
2 using namespace std;
3 int main()
4 {
5 int n,i,j;
6 int a[31][33];
7 while(cin>>n)
8 {
9 a[0][0]=0;a[0][1]=1;a[0][2]=0;
10 cout<<a[0][1]<<endl;
11 for(i=1;i<n;i++)
12 {
13 a[i][0]=0;a[i][i+2]=0;
14 for(j=1;j<=i+1;j++)
15 {
16 a[i][j]=a[i-1][j-1]+a[i-1][j];
17 cout<<a[i][j];
18 if(j!=i+1)
19 cout<<" ";
20 }
21 cout<<"\n";
22 }
23 if(n==i)
24 cout<<"\n";
25 }
26 return 0;
27 }