题解 | #重载运算#

重载运算

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


class Coordinate():
    def __init__(selfxy) -> None:
        self.x = x
        self.y = y
    
    def __str__(self) -> str:
        print(f'({self.x}{self.y})')
        return self.x, self.y

def __add__(c1c2):
    x = c1.x + c2.x
    y = c1.y + c2.y
    newC = Coordinate(x, y)
    return newC

x1, y1 = input().split(' ')
x2, y2 = input().split(' ')
x1 = int(x1)
x2 = int(x2)
y1 = int(y1)
y2 = int(y2)
c1 = Coordinate(x1, y1)
c2 = Coordinate(x2, y2)
c3 = __add__(c1, c2)
c3.__str__()

全部评论

相关推荐

身边有人上海、深圳 6、7k 都去了,真就带薪上班了。
程序员小白条:木的办法, 以后越来越差,还是家附近宅着吧,毕业的人越来越多,岗位都提供不出来,经济又过了人口红利期
点赞 评论 收藏
分享
07-01 13:37
门头沟学院 Java
steelhead:不是你的问题,这是社会的问题。
点赞 评论 收藏
分享
asdasdasda...:19岁,不容易啊可能升个本会好点,现在学历歧视太严重了
点赞 评论 收藏
分享
评论
2
收藏
分享

创作者周榜

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