题解 | #水仙花数#
水仙花数
https://www.nowcoder.com/practice/dc943274e8254a9eb074298fb2084703
#include<iostream>
using namespace std;
int main() {
int a, b, c, num, count=0;
int m, n;
while (cin >> m >> n) {
for (num = m; num <= n; num++) {
a = num / 100;
b = num / 10 % 10;
c = num % 10;
if (a * a * a + b * b * b + c * c * c == num) {
cout << num << " ";
count++;
}
}
if (count == 0) cout << "no";
}
}
上海得物信息集团有限公司公司福利 1170人发布
查看9道真题和解析