题目:一个5位数,判断它是不是回文数。即12321是回文数,个位与万位相同,十位与千位相同。
程序:
#include <stdio.h>
int main(void)
{
int a,b,c,d;
long s;
printf("Please enter a number:");
scanf("%ld",&s);
if(s <= 99999&&s >= 10000)
{
a=s/10000;
b=s/1000%10;
c=s/10%10;
d=s%10;
if ( a ==d && b == c )
printf("%d is a huiwen number.\n",s);
else
printf("%d is not a huiwen number.\n",s);
}
else
printf("it is not a correct number.\n");
return 0;
}
输出样例: