更新
This commit is contained in:
22
Python-100-Days/Day01-15/Day05/palindrome.py
Normal file
22
Python-100-Days/Day01-15/Day05/palindrome.py
Normal file
@@ -0,0 +1,22 @@
|
||||
"""
|
||||
|
||||
判断输入的正整数是不是回文数
|
||||
回文数是指将一个正整数从左往右排列和从右往左排列值一样的数
|
||||
|
||||
Version: 0.1
|
||||
Author: 骆昊
|
||||
Date: 2018-03-02
|
||||
|
||||
"""
|
||||
|
||||
num = int(input('请输入一个正整数: '))
|
||||
temp = num
|
||||
num2 = 0
|
||||
while temp > 0:
|
||||
num2 *= 10
|
||||
num2 += temp % 10
|
||||
temp //= 10
|
||||
if num == num2:
|
||||
print('%d是回文数' % num)
|
||||
else:
|
||||
print('%d不是回文数' % num)
|
||||
Reference in New Issue
Block a user