题解 | #点的距离#

点的距离

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

#include <iostream>
#include <cmath>
using namespace std;
class CPoint {
  public:
    int x, y;
    CPoint(int _x, int _y): x(_x), y(_y) {}
    double operator-(CPoint& p) {
        return sqrt((x - p.x) * (x - p.x) + (y - p.y) * (y - p.y));
    }
};
int main() {
    int m;
    cin >> m;
    while (m--) {
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        CPoint p1(x1, y1), p2(x2, y2);
        printf("%.2lf\n", p1 - p2);
    }
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

06-10 23:36
已编辑
首都经济贸易大学 C++
点赞 评论 收藏
分享
nus2201602...:兄弟,你这个简历撕了丢了吧,就是一坨,去找几个项目,理解项目流程,看几遍就是你的了,看看八股就去干了,多看看牛客里别人发出来的简历,对着写,你这写的啥啊,纯一坨
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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