题解 | #水仙花数#
水仙花数
http://www.nowcoder.com/practice/dc943274e8254a9eb074298fb2084703
#include <stdio.h>
int main(){
int m,n,If=0;
while(scanf("%d%d",&m,&n)!=EOF){
for(;m<=n;m++){
int a,b,c;
a=m%10;
b=m/10%10;
c=m/100;
if((a*a*a+b*b*b+c*c*c)==m){
If=1;
printf("%d ",m);
}
}
if(If==0) printf("no\n");
}
return 0;
}
int main(){
int m,n,If=0;
while(scanf("%d%d",&m,&n)!=EOF){
for(;m<=n;m++){
int a,b,c;
a=m%10;
b=m/10%10;
c=m/100;
if((a*a*a+b*b*b+c*c*c)==m){
If=1;
printf("%d ",m);
}
}
if(If==0) printf("no\n");
}
return 0;
}