# Leetcode 9. Palindrome Number (C語言)
- 題目
Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward.
- 範例
```
Example 1:
Input: 121
Output: true
Example 2:
Input: -121
Output: false
Explanation: From left to right, it reads -121.
From right to left, it becomes 121-.
Therefore it is not a palindrome.
Example 3:
Input: 10
Output: false
Explanation: Reads 01 from right to left. Therefore it is not a palindrome.
```
```c
bool isPalindrome(int x){
if(x<0)return false;
if(x==0)return true;
int i,temp,count=0;
char *arr=(char*)malloc(10);
while(x!=0){
temp=x%10;
arr[count]=temp;
count++;
x/=10;
}
for(i=0;i<count/2;i++){
if(arr[i]!=arr[count-1-i])return false;
}
return true;
}
```
思路:負數直接false,0為true,正數就當成string來看,
int範圍最大2147483647不超過10位數,範圍給10格就行。
每次%取尾數放進array,放完再去array看是否回文就行。