您的位置:首页 > 其它

hdu2032

2015-11-05 15:42 281 查看
http://acm.hdu.edu.cn/showproblem.php?pid=2032

#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<iostream>
using namespace std;

int main()
{
//freopen("in.txt","r",stdin);
int n;
int a[40][40];
memset(a,0,sizeof(a));
a[1][1]=1;
a[2][1]=1;
a[2][2]=1;
for(int i=1;i<=30;i++)
a[i][1]=1;
for(int i=3;i<=30;i++)
{
for(int j=2;j<=30;j++)
{
a[i][j]=a[i-1][j-1]+a[i-1][j];
}
}
while(~scanf("%d",&n))
{
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
if(a[i][j]==0)
continue;
if(j==1)
printf("%d",a[i][j]);
else
printf(" %d",a[i][j]);
}
printf("\n");
}
cout<<endl;
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: