数学上有个水仙花数,他是这样定义的:,它的各位数字的立方和等于其本身,比如:153=1^3+5^3+3^3.

#include <stdio.h>
#include <math.h>
int main(){
int m,n,i,j,k,z,x,temp;
while (scanf("%d%d",&m,&n)!=EOF)
{
if (m>=100 && n<=999 && m<=n){
temp=0;
for (i=m;i<=n;++i){
k=i;
z=0;
for (j=0;j<3;++j){
x=k%10;
z+=pow(x,3);
k/=10;
}
if (z==i){
printf ("%d ",z);
temp=1;
}
}
if (temp==0) printf("no\n");
else printf("\b\n");
}
}
return 0;
}

编译运行都没问题,可就是不通过提示Wrong Answer

程序没有问题,答案也都正确。要说提示Wrong Answer,这里有一个问题,你没有说输入输出的格式,但是如果你的输入输出与要求的不符,机器测评就会通不过的。

温馨提示:答案为网友推荐,仅供参考
相似回答