题解 | #重载运算#

重载运算

https://www.nowcoder.com/practice/342d1b8b0fe3416797bad62d22cbb51a

class Coordinate:
    def __init__(self, a, b):
        self.a = a
        self.b = b

    def __str__(self):
        return '(%s, %s)' % (self.a, self.b)

    def __add__(self, other):
        return Coordinate(self.a + other.a, self.b + other.b)


x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]
c1 = Coordinate(x[0], x[1])
c2 = Coordinate(y[0], y[1])
print(c1 + c2)

全部评论

相关推荐

嗨害嗨我来了:你跟他说开迈巴赫呢,一个月好几万,让学弟尝尝一点小小的社会险恶
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务