题解(求点赞)
2025-11-23 09:58:07
发布于:北京
2阅读
0回复
0点赞
#include <iostream>
using namespace std;
int main() {
for (int num = 100; num <= 999; ++num) {
int hundreds = num / 100; // 百位数字
int tens = (num % 100) / 10; // 十位数字
int units = num % 10; // 个位数字
int sum = hundreds * hundreds * hundreds + tens * tens * tens + units * units * units;
if (sum == num) {
cout << num << endl; // 输出水仙花数
}
}
return 0;
}
这里空空如也






有帮助,赞一个