/* This is my homework today to judge a number whether it's a palindrome/
/ Most of us use array to solve the problem, but I find a way do not need an array.*/
include <stdio.h>
int main(int argc, const char * argv[])
{
int x,m,n=0;
printf("Enter a number:");
scanf("%d",&x);
for(int i=1;i<=x;i=10){
m=x%(i10)/i;
n=m+n*10;
}
if (n==x){
printf("%d is a palindrome\n",x);
}
else{
printf("%d is not a palindrome\n",x);
}
return 0;
}
标签:palindrome,int,invert,number,way,printf,array,smart From: https://www.cnblogs.com/beshoujodaisuki/p/18029457