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

快手公司福利 1244人发布