光动力治疗尖锐湿疹:队列 杨辉三角

来源:百度文库 编辑:杭州交通信息网 时间:2024/04/29 12:59:32
c语言版的 通过队列实现杨辉三角
输出的杨辉三角是正金字塔形式的

include "iostream"
include "math"
using namespace std;
int main()
{
const int x;
int y;
cout<<"输入要打印的几行为N:";
cin>>y;
x=y;
int a[x]={1,1};
for(int i=0;i<x;i++)
{
for(int j=0;j<=i;j++)
{
if(j==i)
{
cout<<a[j]<<endl;
}
else if(j==0)
{
cout<<a[j];
}
else
{
cout<<a[j-1]+a[j];
}
}
}
}