C++ 计算两点间距离 - 线段长度算法
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main() {
double xa, ya, xb, yb;
cin >> xa >> ya;
cin >> xb >> yb;
double length = sqrt(pow(xb - xa, 2) + pow(yb - ya, 2));
cout << fixed << setprecision(3) << length << endl;
return 0;
}
原文地址: https://www.cveoy.top/t/topic/uLi 著作权归作者所有。请勿转载和采集!