def insert_0(s):
if len(s) == 3:
s.insert(0, 0)
if len(s) == 2:
s.insert(0, 0)
s.insert(1, 0)
if len(s) == 1:
s.insert(0, 0)
s.insert(1, 0)
s.insert(2, 0)
return s
def print_f(Max, Min, nums):
for m in Max:
print(m, end = '')
print(' - ', end = '')
for m in Min:
print(m, end = '')
print(' = ', end = '')
for m in nums:
print(m, end = '')
print()
nums = list(map(int, input()))
num = 1
insert_0(nums)
while num != 6174 and num != 0:
Max_n = sorted(nums,reverse = True)
Min_n = sorted(nums)
Max = Max_n[0] * 1000 + Max_n[1] * 100 + Max_n[2] * 10 + Max_n[3]
Min = Min_n[0] * 1000 + Min_n[1] * 100 + Min_n[2] * 10 + Min_n[3]
num = Max - Min
nums = list(map(int, str(num)))
insert_0(nums)
print_f(Max_n, Min_n, nums)
1019 完美通过版
最新推荐文章于 2019-12-26 19:55:14 发布