-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
36 lines (36 loc) · 796 Bytes
/
Copy pathmain.cpp
File metadata and controls
36 lines (36 loc) · 796 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
int Reverse(int n){
int remain;
int reverse = 0;
while (true){
remain = n % 10;
reverse = reverse * 10 + remain;
n = n / 10;
if (n == 0){
break;
}
}
return reverse;
}
int main() {
int i;
for (i = 0; i <= 256; ++i) {
if(i*i == Reverse(i*i)){
printf("%d\n", i);
}
}
int a,b,c,d;
for (a = 1; a <= 9; ++a) {
for (b = 0; b <= 9; ++b) {
for (c = 0; c <= 9; ++c) {
for (d = 0; d <= 9; ++d) {
int n = 1000 * a + 100 * b + 10 * c + d;
if(n * 9 == Reverse(n)){
printf("%d\n", n);
}
}
}
}
}
return 0;
}