计算两点之间的距离
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
//计算两点之间的距离
double x1,y1,x2,y2;
cout<<"please input the two point:"<<endl;
cin>>x1>>y1>>x2>>y2;
cout<<hypot((x2-x1),(y2-y1))<<endl;
}
本文介绍了一个简单的C++程序,用于计算二维平面上任意两点之间的距离。通过使用标准输入输出流和数学库中的hypot函数实现了计算功能。
计算两点之间的距离
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
//计算两点之间的距离
double x1,y1,x2,y2;
cout<<"please input the two point:"<<endl;
cin>>x1>>y1>>x2>>y2;
cout<<hypot((x2-x1),(y2-y1))<<endl;
}
802
4494
1347
2838
1633
860

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