1407241634-hd-杨辉三角.cpp
来源:互联网 发布:淘宝客批量采集软件 编辑:程序博客网 时间:2024/06/02 03:02
#include<stdio.h>
int main()
{
int n;
int i,j,k;
int str[35][35];
str[1][1]=str[2][1]=str[2][2]=1;
for(i=3;i<=30;i++)
for(j=1;j<=i;j++)
{
if(j==1||j==i)
str[i][j]=1;
else
str[i][j]=str[i-1][j-1]+str[i-1][j];
}
while(scanf("%d",&n)==1)
{
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
printf("%d",str[i][j]);
if(j!=i)
printf(" ");
}
printf("\n");
}
printf("\n");
}
return 0;
}
int main()
{
int n;
int i,j,k;
int str[35][35];
str[1][1]=str[2][1]=str[2][2]=1;
for(i=3;i<=30;i++)
for(j=1;j<=i;j++)
{
if(j==1||j==i)
str[i][j]=1;
else
str[i][j]=str[i-1][j-1]+str[i-1][j];
}
while(scanf("%d",&n)==1)
{
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
printf("%d",str[i][j]);
if(j!=i)
printf(" ");
}
printf("\n");
}
printf("\n");
}
return 0;
}
0 0
- 1407241634-hd-杨辉三角.cpp
- hd 2032 杨辉三角
- 1407261645-hd-密码.cpp
- 1407291712-hd-三角形.cpp
- 1408010808-hd-大菲波数.cpp
- 1408011500-hd-N!.cpp
- 1408071108-hd-Milk.cpp
- 1408140917-hd-Bitset.cpp
- 1408182100-hd-ASCII.cpp
- 1408201651-hd-GPA.cpp
- 1408201941-hd-Elevator.cpp
- 1408202033-hd-最小公倍数.cpp
- 1408211519-hd-排序.cpp
- 杨辉三角/帕斯卡三角
- 1407230827-hd-数值统计.cpp
- 1407230852-hd-偶数求和.cpp
- 1407231800-hd-反素数.cpp
- 1407231857-hd-Problem A .cpp
- Android应用程序资源管理器(Asset Manager)的创建过程分析
- 可下拉的PinnedHeaderExpandableListView的实现
- C# 字符串按字节截取
- Android中shape详解
- Android 标签控件
- 1407241634-hd-杨辉三角.cpp
- VS2010运用Format将字符数组转化为CString 格式,并用AfxMessageBox()过程中出现转换乱码问题的解决方案
- 等候在南,我在对面
- Win7 SP1或安装补丁后安装VS2010出现无法安装FrameWork 4.0错误
- hdu 1698 Just a Hook 基本线段树
- js禁止中文输入
- 麦库笔记
- rman—实验—基于日志序列号的不完整恢复
- Mysql导出表结构及表数据 mysqldump用法