#include <stdio.h>
int IsPalindromeNumber(int x){
int div;
int low, high;
div = 1;
while(x/div >= 10){
div = div * 10;
}
while(x != 0){
low = x % 10;
high = x / div;
if(low == high){
x = (x % div) / 10;
div = div / 100;
}
else{
return 0;
}
}
return 1;
}
int main(){
int x;
while(1){
printf("Please input a integer.\n");
scanf_s("%d", &x, 1);
if(IsPalindromeNumber(x)){
printf("%d is a Palindrome Number.\n", x);
}
else{
printf("%d is NOT a Palindrome Number.\n", x);
}
}
return 0;
}
Leetcode IsPalindromeNumber
最新推荐文章于 2024-08-30 15:57:36 发布