题解 | #重载运算#

重载运算

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

class Coordinate(object):
    def __init__(self, x, y):
        self.x=x
        self.y=y

    def __str__(self):
        print((self.x,self.y))

    def __add__(self,other):
        return (self.x + other.x, self.y + other.y)

list1=list(map(int,input().split()))
list2=list(map(int,input().split()))

a=Coordinate(list1[0],list1[1])
b=Coordinate(list2[0],list2[1])
print(a+b)

全部评论

相关推荐

淬月星辉:专利是什么?至少描述一下吧,然后把什么计算机二级、普通话这种拉低格调的证书删掉,不然hr以为你没东西写
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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