#include<iostream>
#include<cmath>
using namespace std;
class location
{
public:
location(double ,double);
void show();
friend double dist(location& d1,location& d2);
private:
double x,y;
};
location::location(double X,double Y)
{
x=X;
y=Y;
}
void location::show()
{
cout<<"点的坐标为:("<<x<<","<<y<<")"<<endl;
}
double dist(location& d1,location& d2)
{
double L;
L=sqrt((d1.x-d2.x)*(d1.x-d2.x)+(d1.y-d2.y)*(d1.y-d2.y));
return L;
}
int main()
{
location A(3,2),B(1,1);
cout<<"A";A.show();
cout<<"B";B.show();
cout<<"俩点间的距离为"<<dist(A,B)<<endl;
system("pause");
return 0;
}
07-23
07-23
07-23
07-24