题解 | 点到直线距离

点到直线距离

https://www.nowcoder.com/practice/1bcdd78060e54812a9c47ebe40c6af65

double getDistance(point P, line L){
    int a=L.point_A.y-L.point_B.y;
    int b=L.point_B.x-L.point_A.x;
    int c=L.point_A.x*L.point_B.y-L.point_A.y*L.point_B.x;
    return(abs(static_cast<double>(a*P.x+b*P.y+c))/sqrt(static_cast<double>(a*a+b*b)));
}

全部评论

相关推荐

双尔:反手回一个很抱歉,经过慎重考虑,您与我的预期暂不匹配,感谢您的投递
点赞 评论 收藏
分享
激昂墓志铭_终章:亚新经典实习3300,转正7k外包。去那干啥,还要加班
投递亚信科技(中国)有限公司等公司6个岗位
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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