主题:杨辉三角的问题
#include<iostream.h>
void main()
{
int n,r,c,m,j=0;
cout<<"请输入行数(小于17):";
cin>>m;
while(m>=17)
{
cout<<"你输入的行数超出范围,请重新输入!"<<endl;
cout<<"请输入行数(小于17):";
cin>>m;
j++;
if(j>=2)
{
cout<<"你的错误输入以达到3次,你无权再输入!"<<endl;
return;
}
}
for(n=0;n<=m-1;n++)
{
for(r=1;r<=15-n;r++)
cout<<" ";//2
c=1;
cout<<c<<" ";//3
for(r=1;r<=n;r++)
{
c=c*(n-r+1)/r;
if(c<=100)
if(c<10)
cout<<c<<" ";//3
else
cout<<c<<" ";//2
else
cout<<c<<" ";//1
}
cout<<endl;
}
}
请问
for(n=0;n<=m-1;n++)
{
for(r=1;r<=15-n;r++)
cout<<" ";//2
c=1;
cout<<c<<" ";//3
for(r=1;r<=n;r++)
{
c=c*(n-r+1)/r;
if(c<=100)
if(c<10)
cout<<c<<" ";//3
else
cout<<c<<" ";//2
else
cout<<c<<" ";//1
}
cout<<endl;
}
}
这一段是什么意思,尤其是空格不懂哦!
知道的告诉一声谢谢!
小弟新手在学C++!
void main()
{
int n,r,c,m,j=0;
cout<<"请输入行数(小于17):";
cin>>m;
while(m>=17)
{
cout<<"你输入的行数超出范围,请重新输入!"<<endl;
cout<<"请输入行数(小于17):";
cin>>m;
j++;
if(j>=2)
{
cout<<"你的错误输入以达到3次,你无权再输入!"<<endl;
return;
}
}
for(n=0;n<=m-1;n++)
{
for(r=1;r<=15-n;r++)
cout<<" ";//2
c=1;
cout<<c<<" ";//3
for(r=1;r<=n;r++)
{
c=c*(n-r+1)/r;
if(c<=100)
if(c<10)
cout<<c<<" ";//3
else
cout<<c<<" ";//2
else
cout<<c<<" ";//1
}
cout<<endl;
}
}
请问
for(n=0;n<=m-1;n++)
{
for(r=1;r<=15-n;r++)
cout<<" ";//2
c=1;
cout<<c<<" ";//3
for(r=1;r<=n;r++)
{
c=c*(n-r+1)/r;
if(c<=100)
if(c<10)
cout<<c<<" ";//3
else
cout<<c<<" ";//2
else
cout<<c<<" ";//1
}
cout<<endl;
}
}
这一段是什么意思,尤其是空格不懂哦!
知道的告诉一声谢谢!
小弟新手在学C++!