2011-12-14 04:47:31
地址:http://acm.hdu.edu.cn/showproblem.php?pid=2032
题意:中文。
代码:
# include <stdio.h>
int tri[35][35] ;
void output (int n)
{
int i, j ;
for (i = 0 ; i < n ; i++)
{
for (j = 0 ; j < i+1 ; j++)
if (j == 0) printf ("%d", tri[i][j] ) ;
else printf (" %d", tri[i][j]) ;
puts ("" );
}
puts ("" ) ;
}
int main ()
{
int i, j, n ;
for (i = 0 ; i < 30 ; i++)
tri[i][0] = 1 ;
for (i = 1 ; i < 30 ; i++)
for (j = 1 ; j <= i ; j++)
tri[i][j] = tri[i-1][j] + tri[i-1][j-1] ;
while (~scanf ("%d", &n))
output (n) ;
return 0 ;
}