题解 | 输出水仙花数
输出水仙花数
https://www.nowcoder.com/practice/dabaf13009ef4d0cbf22302fd6a530a6
#include <iostream>
#include<cmath>
using namespace std;
int main() {
// write your code here......
for (int i = 100; i <= 999; i++) {
if (pow(i % 10, 3) + pow((i / 10) % 10, 3) + pow((i / 100) % 10, 3) == i)
cout << i << endl;
}
return 0;
}

查看1道真题和解析