void main()
{
long num,smallnum;
scanf("%d",&num);
smallnum = num;
int start=1;
int count=0;
do{
start*=10;
count++;
}while(num%start!=num);
printf("本數是%d位\n",count);
int i;
int yes=1;
if(count%2==0){
yes=0;
}
int loopcount = count/2;
int innercounter=1;
int bigsum=1;
int smallsum=1;
for(i=1;i<=loopcount;i++){
smallsum=1;
for(innercounter=1;innercounter<=i;innercounter++){
smallsum = smallsum*10;
}
bigsum=1;
for(innercounter=1;innercounter<=(count-i);innercounter++){
bigsum = bigsum*10;
}
int small = smallnum%(smallnum/10);
smallnum = smallnum/=10;
int big = num/bigsum;
num = num%bigsum;
if(big!=small){
yes=0;
break;
}
}
if(yes==1){
printf("此數是回文數.");
}else{
printf("此數不是回文數.");
}
}
摘自 張仁陽專欄