题解 | 绕距

绕距

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

#include<bits/stdc++.h>
#include <iomanip>
using namespace std;
struct point_start {
    double x,y;
};
struct point_end {
    double x,y;
};
point_start s;
point_end e;
long double de,dm,result;
int main ()
{
    cin>>s.x>>s.y;
    cin>>e.x>>e.y;
    de = sqrt(pow((s.x-e.x),2)+pow((s.y-e.y),2));
    dm = fabs(s.x-e.x)+fabs(s.y-e.y);
    result = fabs(dm-de);
    cout<<fixed<<setprecision(18)<<result;
    return 0;
}

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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