Skip to content

Commit 507371c

Browse files
authored
Create 9_Palindrome Number
1 parent 9db184d commit 507371c

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

9_Palindrome Number

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class Solution {
2+
public:
3+
bool isPalindrome(int x) {
4+
5+
double reverse = 0;
6+
double n;
7+
double org_x = x;
8+
9+
while(x != 0){
10+
n = x % 10;
11+
reverse = reverse * 10 + n;
12+
x = x / 10;
13+
}
14+
if (reverse == org_x && org_x >=0)
15+
return true;
16+
else
17+
return false;
18+
}
19+
};

0 commit comments

Comments
 (0)