题解 | #回文对称数#

回文对称数

http://www.nowcoder.com/practice/5b143af8328f4e42adf5e10397ae44ef

提供两种解法

for循环

a=int(input())
for x in range(1,a+1):
    if str(x)[::-1]==str(x):
        print(x)

while循环

a=int(input())
x=1
while x < a:
    if str(x)[::-1]==str(x):
        print(x)
    x+=1
全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务