Palindrome number of the positive and negative sequence is the same number, so we put this number of high-low-level exchange, that is, 1234->4321, and then use the new number to compare with the previous digital exchange is equal, that is, can determine whether this number is a palindrome number. Note : Negative numbers are not palindrome numbers.
Judge whether a number of palindrome number (palindrome number is also a number, the number is characterized by positive and negative sequence is the same number, such as: 12321,3443)
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
int if_palindrome_num (int n)
{
assert (n > 0);
int num = n;
int res = 0;
Do
{
res = res * + num%;
num = NUM/10;
} while (num);
if (res = = N)
{return
1;
}
return 0;
}
int main ()
{
int n = 12321;
int temp = 0;
temp = If_palindrome_num (n);
if (temp = 0)
{
printf ("The%d is not palindrome number.\n", n);
}
else
{
printf ("The%d is palindrome number.\n", n);
}
System ("pause");
return 0;
}