本题用C++写要用高精度,py直接模拟即可
py中的字符串反转可以用切片操作,对于字符串s,将它反转:s = s[::-1]
A = input()
B = A[::-1]
cnt = 0
success = True
while A != B:
if cnt == 10:
success = False
break
C = int(A) + int(B)
print(f"{A} + {B} = {C}")
A = str(C)
B = A[::-1]
cnt += 1
if success:
print(f"{A} is a palindromic number.")
else:
print("Not found in 10 iterations.")