Determine whether a number is a palindrome.
Let n be an arbitrary natural number. If the natural number n1 and n obtained by reversing the digits of n are equal, then n is called a palindrome number. For example, if n=1234321, then n is the number of palindrome; but if n=1234567, then n is not the number of palindrome
- To judge whether a number is a palindrome, you only need to output it in reverse order. If the output number is equal to the original number, it is a palindrome number, otherwise it is not a palindrome number
#include <stdio.h>
int main()
{
int num,x;
int new=0;
scanf("%d",&num);
x=num;
while(x!=0)//将数倒序输出
{
new=new*10+x%10;
x=x/10;
}
if(num==new)
printf("%d是回文数",num);
else
printf("%d不是回文数",num);
return 0;
}