题解 | 点的距离

点的距离

https://www.nowcoder.com/practice/3468bd027c5a410e895150b0d5b13502

#include <bits/stdc++.h>
using namespace std;
class CPoint{
public:
    int x,y;
    CPoint(int x,int y){
        this->x=x;
        this->y=y;
    }
};
double operator-(CPoint&a,CPoint&b){
    return sqrt(pow(a.x-b.x,2)+pow(a.y-b.y,2));
}
int main() {
    int n;
    cin>>n;
    for(int i=0;i<n;++i){
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        CPoint A(a,b),B(c,d);
        printf("%.2f\n",A-B);
    }
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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