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