#include<stdio.h>
int main(){
int m,n,i,a,b,c,t;
while(scanf("%d%d",&m,&n)!=EOF){
t=0;
for(i=m;i<=n;i++){
a=i%10;
b=(i/10)%10;
c=i/100;
if((a*a*a+b*b*b+c*c*c)==i){
if(t!=0)
printf(" ");
printf("%d",i);
t++;
}
}
if(t==0)
printf("no");
printf("\n");
}
return 0;
}
【转】网上采用数组存储水仙花数再输出的代码参考:http://blog.sina.com.cn/s/blog_76eabc150100reao.html