题解 | #重载运算符#

重载运算符

https://www.nowcoder.com/practice/7b1e4ffc39604be3b15959ce329da490

from math import radians, sin
class Angle:
    def __init__(self, degrees):
        self.degrees = degrees
    def __sub__(self, other):
        return Angle(self.degrees - other.degrees)
    def sine(self):
        return sin(radians(self.degrees))
for _ in range(int(input())):
    angle1, angle2 = map(int, input().split())
    a1, a2 = Angle(angle1), Angle(angle2)
    print("{:.2f}".format((a1 - a2).sine()))

全部评论

相关推荐

合不合适,我自己说了才算
码农索隆:hr:“真执着啊,来我公司当法人吧”
点赞 评论 收藏
分享
Yki_:你要算时间成本呀,研究生两三年,博士三四年,加起来就五六年了,如果你本科去腾讯干五年,多领五年的年薪,加上公司内涨薪,可能到时候十五年总薪资也跟博士差不多
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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