题解 | #重载运算#

重载运算

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,x,y):
        self.x=x[0]+y[0]
        self.y=x[1]+y[1]
        
x=[int(i) for i in input().split()]
y=[int(i) for i in input().split()]
c=Coordinate(x,y)
c.__add__(x,y)
c.__str__()
全部评论

相关推荐

08-06 08:33
四川大学 Java
OPPO官方内推:卧槽!!!啥破公司啊!!!
投递OPPO等公司10个岗位
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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