[恢]hdu 2032

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 ;
}



posted @ 2012-01-06 14:33  Seraph2012  阅读(138)  评论(0编辑  收藏  举报