采用队列,编写程序打印出杨辉三角形 数据结构(C语言版) 帮帮忙啊~~

采用队列,编写程序打印出杨辉三角形。11 11 2 11 3 3 11 4 6 4 11 5 10 5 1
2025-03-03 21:50:37
推荐回答(1个)
回答1:

#include
#include
using namespace std;

int main()
{
int i,j;
int yang[10][10];
int n;

cout<<"Please input the value of the line(<=10)!" < cin>>n;

if(n>10 || n<=0)
{
cout<<"Data error!"< }

else
{
for(i=0;i {
yang[i][i]=1;
yang[i][0]=1;
}
for(i=2;i {
for(j=1;j {
yang[i][j]=yang[i-1][j-1]+yang[i-1][j];
}
}

for(i=0;i {
for(j=0;j<=i;j++)
{
cout< cout<<'\n';
}
}
}

return 0;
}