import time
# 格式化成2021-08-16 17:20:15形式
nowTime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
print(nowTime)
def ThreeNum():
three = []
count = 0
for i in range(100, 1000):
n1 = i // 100 # 取整除 百位
n2 = (i - n1 * 100) // 10 # 十位
n3 = i % 10 # 个位
n = pow(n1, 3) + pow(n2, 3) + pow(n3, 3)
if i == n:
count = count + 1
three.append(n)
print("水仙花数有 %s 个:%s" % (count, three))
def FourNum():
four = []
count = 0
for i in range(1000, 10000):
n1 = i // 1000 # // 取整除 千位
n2 = (i - n1 * 1000) // 100 # 百位
n3 = i % 10 # 个位
n4 = (i - n1 * 1000 - n2 * 100) // 10 # 十位
n = pow(n1, 4) + pow(n2, 4) + pow(n3, 4) + pow(n4, 4)
if i == n:
Python水仙花数、四叶玫瑰数、五角星数的可选操作
最新推荐文章于 2021-10-25 12:38:09 发布