题解 | #重载运算符#

重载运算符

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()))

全部评论

相关推荐

不愿透露姓名的神秘牛友
07-08 10:39
一个证都没 我能填什么
程序员小白条:别人有,你为什么没有,还是这个道理,社会就是比较,竞争,淘汰,你要安逸,那么就要做好淘汰的准备
点赞 评论 收藏
分享
MinJerous:虽然我一直说 计算机不怎么卡学历 但是至少得一本
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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