"Palindrome" is a sentence to read and read through. It is a rhetorical way and word games, such as "I for everyone, everyone for me" and so on. In mathematics there are also such a number of numbers that have this characteristic and become palindrome numbers (palindrome number).
set N is a random natural number. If the numbers of n are reversed and the natural number N1 is equal to N, then N is a palindrome number. For example, if n=1234321, then n is a palindrome number. But if n=1234567, then n is not a palindrome number.
On the code:
#include <stdio.h> #define true 1 #define false 0 int Huiwenshu (int n) {int p;p=n; int k=0;//The n in reverse and saves it in the K variable while (p!=0) {K=K*10+P%10;P=P/10;} Infer the result after the reverse of the K and the original input number n is equal, equal return Trueif (k==n) return True;elsereturn false;} int main (void) {printf ("Please input number:\n"); static int num; static int ret; SCANF ("%d", &num); ret = Huiwensh U (num), if (1 = = ret) printf ("Palindrome number \ n"), elseprintf ("not palindrome \ n"); return 0;}
Execution Result:
Watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqv/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity /center ">
The algorithm of palindrome number in C language