friend double dist(point , point);
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
class point
{
double x,y;
public:
point(double xx,double yy) { x=xx, y=yy; }
friend double dist(point , point);
};
double dist(point p1,point p2)
{ return sqrt( (p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y) ); }
int main()
{ int n;
double x1,x2,y1,y2;
cin>>n;
while (n--)
{ cin>>x1>>y1>>x2>>y2;
point p1(x1,y1),p2(x2,y2);
cout<<fixed <<setprecision(3)<< dist(p1,p2) <<endl;
}
}
friend double dist(point p1,point p2) { return sqrt( (p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y) ); }
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
class point
{
double x,y;
public:
point(double xx,double yy) { x=xx, y=yy; }
friend double dist(point p1,point p2)
{ return sqrt( (p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y) ); }
};
int main()
{ int n;
double x1,x2,y1,y2;
cin>>n;
while (n--)
{ cin>>x1>>y1>>x2>>y2;
point p1(x1,y1),p2(x2,y2);
cout<<fixed <<setprecision(3)<< dist(p1,p2) <<endl;
}
}
类有元
friend class test;
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
class point;
class test
{ public:
double dist(point,point); };
class point
{ double x,y;
public:
point(double xx,double yy) { x=xx, y=yy; }
friend class test;
};
double test::dist(point p1,point p2)
{ return sqrt( (p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y) ); }
int main()
{ int n; double x1,x2,y1,y2; test t;
cin>>n;
while (n--)
{ cin>>x1>>y1>>x2>>y2;
point p1(x1,y1),p2(x2,y2);
cout<<fixed<<setprecision(3)<<t.dist(p1,p2)<<endl;
}
}

friend double test::dist(point , point);
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
class point;
class test
{
public:
double dist(point,point);
};
class point
{ double x,y;
public:
point(double xx,double yy) { x=xx, y=yy; }
friend double test:: dist(point , point);
};
double test::dist(point p1,point p2)
{ return sqrt( (p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y) ); }
int main()
{ int n; double x1,x2,y1,y2; test t;
cin>>n;
while (n--)
{ cin>>x1>>y1>>x2>>y2;
point p1(x1,y1),p2(x2,y2);
cout<<fixed<<setprecision(3)<<t.dist(p1,p2)<<endl;
}
}