题解 | #点的距离#
点的距离
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")
查看11道真题和解析
