題目: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;
}
};