C语言 判断是不是回文数?

2024-11-16 18:58:13
推荐回答(1个)
回答(1):

程序源代码:
main(
)
{
long
ge,shi,qian,wan,x;
scanf("%ld",&x);
wan=x/10000;
qian=x%10000/1000;
shi=x%100/10;
ge=x%10;
if
(ge==wan&&shi==qian)/*个位等于万位并且十位等于千位*/
printf("this
number
is
a
huiwen\n");
else
printf("this
number
is
not
a
huiwen\n");
}
我的代码:
main()
{
int
a,b,c,d;
long
int
n;
scanf("%ld",&n);
a=n/10000;
b=(n%10000)/1000;
c=(n%100)/10;
d=n%10;
if(a==d&&b==c)
printf("this
%ld
is
a
hui
wen\n",n);
else
printf("this
%ld
is
not
a
hui
wen\n",n);
}