有帮助,请点赞
2025-09-25 20:13:21
发布于:内蒙古
0阅读
0回复
0点赞
#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
// 判断是否是三位数
if (n < 100 || n > 999) {
cout << "NO" << endl;
return 0;
}
// 提取各位数字
int a = n / 100; // 百位
int b = (n / 10) % 10; // 十位
int c = n % 10; // 个位
// 计算立方和
int sum = a*a*a + b*b*b + c*c*c;
// 判断是否为水仙花数
if (sum == n) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
return 0;
}
这里空空如也


有帮助,赞一个