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