主题:[讨论]vc初学者,请爱护
这是一个求五行杨辉三角的程序,我没发现什么错误,但运行起来很有问题,还请各位老师指教
# include "iostream.h"
void main()
{
int s=1,l=1,z,m,n;
for (int i=0;i<5;i++)
{
n=i;
for (int a=1;a<=4-i;a++)
{
cout<<" ";
}
if (i==0)
{
cout<<1;
}
else
{
for (int c=0;c<=i;c++)
{
if (c==0)
{
cout<<1<<" ";
}
else
{
m=1;
for (int b=1;b<=c;b++)
{
s=s*m;
m=m+1;
l=l*n;
n=n-1;
}
z=l/s;
cout<<z<<" ";
}
}
}
cout<<endl;
}
}
# include "iostream.h"
void main()
{
int s=1,l=1,z,m,n;
for (int i=0;i<5;i++)
{
n=i;
for (int a=1;a<=4-i;a++)
{
cout<<" ";
}
if (i==0)
{
cout<<1;
}
else
{
for (int c=0;c<=i;c++)
{
if (c==0)
{
cout<<1<<" ";
}
else
{
m=1;
for (int b=1;b<=c;b++)
{
s=s*m;
m=m+1;
l=l*n;
n=n-1;
}
z=l/s;
cout<<z<<" ";
}
}
}
cout<<endl;
}
}