|
发表于 2020-3-31 19:49:02
|
显示全部楼层
- def get_area(x,y,z):
- def model(x,y):
- return x ** 2 + y ** 2
- def dot_product(x,y):
- return x[1] * y[1] + x[0] * y[0]
- x_y = model(x[0] - y[0], x[1] - y[1])
- x_z = model(x[0] - z[0], x[1] - z[1])
- v1 = [i - j for i in x for j in y]
- v1 = v1[:1] + v1[3:]
- v2 = [i - j for i in x for j in z]
- v2 = v2[:1] + v2[3:]
- return ((x_y * x_z - dot_product(v1,v2))**0.5)/2
- points = input('输入点集:')
- points = list(points)
- count = 0
- list1 = []
- list2 = []
- for i in points:
- if i.isnumeric():
- count += 1
- list1.append(int(i))
- if count>=2 :
- count = 0
- list2.append(list1)
- list1 = []
- points = list2
- listc = []
- for p in points:
- listb = []
- for i in points:
- lista = []
- for e in points:
- lista.append(get_area(p,i,e))
- listb.append(max(lista))
- listc.append(max(listb))
- print(max(listc))
复制代码 |
|