杭电acm2010提交总是Presentation Error,怎么回事。。。
using namespace std;
int main ( )
{
int x,y,z;
int i, m,n,t,p;
while (cin >> m >> n)
{
p=0;
if (m>n)
{
t=m;
m=n;
n=t;
}
for (i=m; i<=n; i++)
{
x=i/100;
y=(i-x*100)/10;
z=i%10;
if(i==x*x*x+y*y*y+z*z*z)
{
if(p==0)
cout << i << ' ';
else
cout << i << ' ';
p++;
}
}
if(p==0)
cout << "no" << endl;
else
cout << endl;
}
system ("pause");
return 0;
} 展开
#include <iostream>
using namespace std;
int main ( )
{
int x,y,z;
int i, m,n,t,p,flag;
while (cin >> m >> n)
{
flag=0;
p=0;
if (m>n)
{
t=m;
m=n;
n=t;
}
for (i=m; i<=n; i++)
{
x=i/100;
y=(i-x*100)/10;
z=i%10;
if(i==x*x*x+y*y*y+z*z*z)
{
//if(p==0) 这个没必要
printf(flag++? " %d":"%d",i);//cout << i << ' ';//这里格式错了,因为最后一组数据后面不能有空格
//else 没必要
//cout << i << ' '; 没必要
p++;
}
}
if(p==0)
cout << "no" << endl;
else
cout << endl;
}
system ("pause");
return 0;
}
//你的是格式错误,
亲测通过 望采纳