玩转C语言:如何快速判断五位数是否为回文数?
最编程
2024-01-28 15:38:02
...
int main()
{
long wan, qian, bai, shi, ge,x;
scanf_s("%d", &x);
//取该数个,十,百,千,万位上的数字
wan = x / 10000;
qian = x % 10000 / 1000;
bai = x % 1000 / 100;
shi = x % 100 / 10;
ge = x % 10;
if (wan == ge && qian == shi)//回文数的条件:万位和各位上的数字相同,十位和千位上的数字相同
printf("%lld is hui wenshu", x);
else
printf("%lld not is hui wen shu ",x);
return 0;
}