题目:https://leetcode.com/problems/palindrome-number/?tab=Description
题意:问一个数字串是不是回文串
只要分解它,然后从两边往前面比较即可。
class Solution {
public:
bool isPalindrome(int x) {
if(x<0){
return false;
}
int c[100];
int i=0;
while(x){
c[i++]=x%10;
x=x/10;
}
bool flag=true;
for(int j=0;j<i;j++){
if(c[j]==c[i-j-1]){
}else{
flag=false;
}
}
return flag;
}
};