class Vector3d:
def __init__(self, x, y, z):
self.__x = x
self.__y = y
self.__z = z
def length(self):
# 请在这里补充代码,完成本关任务
#********** Begin *********#
#********** End *********#
# 请在这里增加3个特殊方法,分别用来支持加法运算符、减法运算符以实现两个三维向量间的加法和减法运算
#********** Begin *********#
#********** End *********#
if __name__=="__main__":
x1, y1, z1 = [float(x) for x in input().split()]
m1 = Vector3d(x1, y1, z1)
print('The m1 is', m1)
print('Length of m1 is {:.2f}'.format(m1.length()))
x2, y2, z2 = [float(x) for x in input().split()]
m2 = Vector3d(x2, y2, z2)
print('The m2 is', m2)
print('Length of m2 is {:.2f}'.format(m2.length()))
m3 = m1 + m2
print('The m3 is', m3)
print('Length of m1+m2 is {:.2f}'.format(m3.length()))
m4 = m1 - m2
print('The m4 is', m4)
print('Length of m1-m2 is {:.2f}'.format(m4.length()))
输入
依次输入两组坐标值,例如:
-73.79 77.85 92.49
3.14 -93.94 -52.10
输出
The m1 is (-73.79 77.85 92.49) Length of m1 is 141.63 The m2 is (3.14 -93.94 -52.10) Length of m2 is 107.47 The m3 is (-70.65 -16.09 40.39) Length of m1+m2 is 82.96 The m4 is (-76.93 171.79 144.59) Length of m1-m2 is 237.35
样例
标准输入 复制文本 |
-73.79 77.85 92.49 3.14 -93.94 -52.10 |
标准输出 复制文本 |
The m1 is (-73.79 77.85 92.49) Length of m1 is 141.63 The m2 is (3.14 -93.94 -52.10) Length of m2 is 107.47 The m3 is (-70.65 -16.09 40.39) Length of m1+m2 is 82.96 The m4 is (-76.93 171.79 144.59) Length of m1-m2 is 237.35 |