#include <iostream>
#include<iomanip>
#include<cmath>
using namespace std;
int main()
{
float x1, x2, y1,y2 ,d;
while (cin >> x1>> y1>> x2>>y2)
{
d = sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));
cout << setiosflags(ios::fixed) << setprecision(2) << d << endl;
}
return 0;
}
此博客展示了一段C++代码,用于计算两点间的距离。代码通过输入两点的坐标,利用公式计算距离,并将结果保留两位小数输出。
440

被折叠的 条评论
为什么被折叠?



