题解 | #重载运算#
重载运算
https://www.nowcoder.com/practice/342d1b8b0fe3416797bad62d22cbb51a
class Coordinate:
def __init__(self, x, y):
self.x = x
self.y = y
def __str__(self):
print(f'({self.x}, {self.y})')
def __add__(self,cd): # 传入一个新的对象,分别将x与y坐标分别相加
self.x += cd.x
self.y += cd.y
def main():
x1, y1 = list(map(int, input().split())) # 利用map函数和list函数将输入字符串转化为整数型,并迭代输出,传给x1,x2
x2, y2 = list(map(int, input().split()))
c1 = Coordinate(x1, y1)
c2 = Coordinate(x2, y2)
c1.__add__(c2)
c1.__str__()
main()

