题解 | #三角形相加#

三角形相加

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)

全部评论

相关推荐

点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务