初学者求教学
百位数比个位数大1,十位数是3,个位数是十位数的三倍用 python 咋解
def find_number(): num = 100 while num <= 999: hundreds = num // 100 tens = (num // 10) % 10 units = num % 10 if hundreds == units + 1 and tens == 3 and units == tens * 2: return num num += 1 return None result = find_number() if result: print(result) else: print("没有找到符合条件的数")
[此贴子已经被作者于2023-5-19 20:59编辑过]