题解 | #三角形相加#

三角形相加

https://www.nowcoder.com/practice/cb867ebc313f480cbbf0a1b334d3a1fc

class CTriangle:
    def __init__(self, x, y):
        self.x = x
        self.y = y
    def __add__(self, other):
        return CTriangle(self.x + other.x, self.y + other.y)
    def __str__(self):
        return 'A(0,{}),B(0,0),C({},0)'.format(self.y, self.x)
ans = CTriangle(0, 0)
while True:
    y, x = map(int, input().split())
    if y == 0:
        print(ans)
        break
    ans += CTriangle(x, y)

全部评论

相关推荐

这是什么操作什么意思,这公司我服了...
斯派克spark:意思是有比你更便宜的牛马了
点赞 评论 收藏
分享
06-13 10:15
门头沟学院 Java
想去夏威夷的大西瓜在...:我也是27届,但是我现在研一下了啥项目都没有呀咋办,哎,简历不知道咋写
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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