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;
|
|
}
|
|
|
|
int main() {
|
|
for (int i = 100; i < 1000; i++)//输出所有的水仙花数
|
|
if (isSXH(i))
|
|
printf("%d\n", i);
|
|
return 0;
|
|
} |