示例代码:
#include <stdio.h>
int main(void)
{
int n = 0 ;
scanf("%d",&n);
int i = 0 ;
int a = 0 , b = 0 , c = 0 , d = 0 , e = 0 , f = 0;
for (i = 10000 ; i < 1000000 ; i ++)
{
a = i/100000;
b = i/10000%10;
c = i/1000%10;
d = i/100%10;
e = i/10%10;
f = i%10;
if (i<100000)
{
if (b==f && c == e && b+c+d+e+f == n)
{
printf("%d\n",i);
}
}
else
{
if (a == f && b==e && c == d && a+b+c+d+e+f == n)
{
printf("%d\n",i);
}
}
}
return 0;
}