【C】#水仙花数#
水仙花数
https://www.nowcoder.com/practice/dc943274e8254a9eb074298fb2084703
#include <stdio.h> #include <math.h> int main() { int m, n, flag = 0; while (scanf("%d %d", &m, &n) != EOF) { for (int i = m; i <= n; i++) { int sum = 0; int tmp = i; for (int j = 0; j < 3; j++) { sum += pow(tmp % 10, 3); tmp /= 10; } if (sum == i) { flag = 1; printf("%d ", i); } } if (flag == 0) printf("no\n"); else printf("\n"); } return 0; }