A356.欧几里德距离
2025-08-15 20:19:49
发布于:江苏
0阅读
0回复
0点赞
勾股定理。别搬运我的代码,因为它写得不好!!!
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
//存储点的信息
struct point{
int x, y;
} a, b;
//测距函数
double dist(point a, point b) {
int dx=b.x-a.x, dy=b.y-a.y;
return sqrt(dx*dx+dy*dy);
}
int main() {
point a, b;
cin >> a.x >> a.y >> b.x >> b.y;
cout << fixed << setprecision(2) << dist(a, b);
return 0;
}
这里空空如也
有帮助,赞一个