求满足这样条件的回文数:是五位或六位,且回文数的各个位之和等于输入的一个数
程序
n=int(input())
a,b,c=0,1,0
while a<10 and b<10 and c<10:
if 2*(a+b)+c==n:
print(b,end='')
print(a,end='')
print(c,end='')
print(a,end='')
print(b)
if c<9:
c+=1
elif a<9:
c=0
a+=1
else:
a,c,b=0,0,b+1
a,b,c=0,0,1
while a<10 and b<10 and c<10:
if 2*(a+b+c)==n:
print(c,end='')
print(b,end='')
print(a,end='')
print(a,end='')
print(b,end='')
print(c)
if a<9:
a+=1
elif b<9:
a=0
b+=1
else:
a,b,c=0,0,c+1