Skip to content

Commit 7db03d7

Browse files
authored
Merge pull request #41 from Ericyuanhui/test
palindrome
2 parents d010fa7 + 6dd5982 commit 7db03d7

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#include <iostream>
2+
3+
using namespace std;
4+
5+
int palindrome(int value) {
6+
int temp = value;
7+
int number = value;
8+
int sum = 0;
9+
while (number) {
10+
sum = sum*10 + number%10;
11+
number = number/10;
12+
}
13+
if (sum == temp) {
14+
return 0;
15+
}
16+
return -1;
17+
}
18+
19+
int main() {
20+
cout << "palindrome" << endl;
21+
int result = palindrome(12321);
22+
cout << "result is " << result << endl;
23+
int fail = palindrome(12345);
24+
cout << "fail is " << fail << endl;
25+
return 0;
26+
}
27+

0 commit comments

Comments
 (0)