标签:print NPU def get put 排列 png code alt
class MaxPerimeter:
def __init__(self,alist):
self.alist = alist
def getmaxerimeter(self):
alist.sort(reverse=True) # 将列表中的数逆序排列
for i in range(len(alist)-2):
# 取最大的三边,能构成三角形,其周长最大
if alist[i+2]+alist[i+1] > alist[i]:
return alist[i]+ alist[i+1] + alist[i+2]
return 0
alist = list(map(int,input("Enter a list:\n").split( )))
print(MaxPerimeter(alist).getmaxerimeter())
Enter a list:
2 1 2
5
标签:print NPU def get put 排列 png code alt
原文地址:https://www.cnblogs.com/sinlearn/p/12831473.html