You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
#include<bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
|
|
//是不是水仙花数
|
|
bool isSXH(int n) {
|
|
int s = 0, m;
|
|
m = n;
|
|
while (m) {
|
|
int a = m % 10;
|
|
m = m / 10;
|
|
s += a * a * a;
|
|
}
|
|
return (s == n) ? true : false;
|
|
}
|
|
|
|
int main() {
|
|
for (int i = 100; i <= 999; i++) {
|
|
if (isSXH(i)) cout << i << " ";
|
|
}
|
|
return 0;
|
|
}
|
|
|