输出和为n的回文数

这里写图片描述

#include<stdio.h> 
int main()
{
int a,b,c,d,e,f,n;
long i;
scanf("%d",&n);
for(i=10000;i<1000000;i++)
{
if(i<100000)
{
a = i / 10000 % 10;
b = i / 1000 % 10;
c = i / 100 % 10;
d = i / 10 % 10;
e = i / 1 % 10;
if(a==e && b==d && a+b+c+d+e==n)
{
printf("%ld\n",i);
}
}
else if(i>=100000)
{
a = i / 100000 % 10;
b = i / 10000 % 10;
c = i / 1000 % 10;
d = i / 100 % 10;
e = i / 10 % 10;
f = i / 1 % 10;
if(a==f && b==e && c==d && a+b+c+d+e+f==n)
{
printf("%ld\n",i);
}
}
}
}

这里写图片描述

猜你喜欢

转载自blog.csdn.net/SRXxxx1111/article/details/81591023