求两点距离

在平面直角坐标系中求两点的距离。

输入

输入有若干行,每行四个浮点数,分别代别两个坐标点(a,b)和(c,d)。

输出

对于每组数据,对应输出这两点之间的距离。结果保留两位小数。

#include

#include
#include
using namespace std;
#define PI 3.14159
struct point{
    double a,b;
};
int main()
{
   point x,y;
    while(cin>>x.a>>x.b>>y.a>>y.b)
    {
    double distance;
    distance=pow(x.a-y.a,2)+pow(x.b-y.b,2);
    cout<     }

}
结构体设置点,math函数库pow函数,sqrt函数辅助运算 ,然后用iomanip中进行输出设置

你可能感兴趣的:(蓝桥杯,c++)