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