题解 | #水仙花数#
水仙花数
https://www.nowcoder.com/practice/dc943274e8254a9eb074298fb2084703
#include <stdio.h>
#include <math.h>
int main() {
int m, n, cnt = 0, res, flag = 0;
while (scanf("%d %d", &m, &n) != EOF) {
getchar(); // 吸收输入缓冲区的换行符
for (; m <= n; m++) {
res = pow((m % 10), 3) + pow((m % 100 / 10), 3) + pow((m % 1000 / 100), 3);
if (res == m) {
printf("%d ", res);
flag = 1;
}
}
if (flag == 0) {
printf("no\n");
}
}
return 0;
}