presentation error(C++高手谢谢)
来源:百度知道 编辑:UC知道 时间:2024/06/08 19:39:52
题目:
输入整数n,输出n行的如下图案:
*
**
***
****
*****
******
*******
********
我的程序:
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
int a,b,n;
cin>>n;
for (a=1;a<=n;a=a+1)
{cout<<endl;
for(b=1;b<=a;b=b+1)
{cout<<"*";}
}
system("PAUSE");
return EXIT_SUCCESS;
}
在C++中运行正确的
可是上传倒老师地方,系统说是Presentation Error
输入整数n,输出n行的如下图案:
*
**
***
****
*****
******
*******
********
我的程序:
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
int a,b,n;
cin>>n;
for (a=1;a<=n;a=a+1)
{cout<<endl;
for(b=1;b<=a;b=b+1)
{cout<<"*";}
}
system("PAUSE");
return EXIT_SUCCESS;
}
在C++中运行正确的
可是上传倒老师地方,系统说是Presentation Error
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
int a,b,n;
cin>>n;
for (a=1;a<=n;a=a+1)
{for(b=1;b<=a;b=b+1)
{cout<<"*";}
cout<<endl;
}
system("PAUSE");
return EXIT_SUCCESS;
}
先输出*再换行看看
我建议你写成纯C++风格的版本
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
int a,b,n;
cin>>n;
for (a=1;a<=n;a+=1)
{for(b=1;b<=a;b+=1)
{
cout<<"*";
}
cout<<endl;
}
cout<<endl;
system("PAUSE");
return 0;
}