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