'commit'
This commit is contained in:
21
TangDou/LuoGuBook/3_3_0.cpp
Normal file
21
TangDou/LuoGuBook/3_3_0.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
//是不是水仙花数
|
||||
bool isSXH(int n) {
|
||||
int s = 0, m;
|
||||
m = n;
|
||||
while (m) {
|
||||
int a = m % 10;
|
||||
s += a * a * a;
|
||||
m /= 10;
|
||||
}
|
||||
return s == n;
|
||||
}
|
||||
|
||||
int main() {
|
||||
for (int i = 100; i <= 999; i++)
|
||||
if (isSXH(i)) cout << i << " ";
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user