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