题解 | 两点间距离

两点间距离

https://www.nowcoder.com/practice/94712d6f654143379f8ea5847d9d6225

import sys
import re
import math
class Point:
    def __init__(self, a=0, b=0):
        self.x = a
        self.y = b
#
# 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
#
# 计算A点与B点之间的距离
# @param point_A Point类 A点
# @param point_B Point类 B点
# @return double浮点型
#
class Solution:
    def calculateDistance(self , point_A: Point, point_B: Point) -> float:
        # write code here
        return math.sqrt((point_A.x -point_B.x)**2 +(point_A.y - point_B.y)**2)
    
if __name__ == "__main__":
    for line in sys.stdin:
        a = re.findall(r'\d+',line)
        p1 = Point()
        p1.x = int(a[0])
        p1.y = int(a[1])

        p2 = Point()
        p2.x = int(a[2])
        p2.y = int(a[3])
        
        print(Solution().calculateDistance(p1,p2))











全部评论

相关推荐

03-07 17:51
已编辑
南华大学 后端工程师
asdasdasda...:也不知道是不是真的被逼呢,也有可能女方有很多东西瞒着男方,这种东西男方什么情况都不知道全靠女方说,很难评的
点赞 评论 收藏
分享
03-04 17:07
南昌大学 Java
点赞 评论 收藏
分享
03-08 18:11
门头沟学院 Java
想要实习的牛:这么牛逼的简历都吃瘪吗🌚那我不寄了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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