#include<iostream>
#include<cmath>
using namespace std;
class Point
{private:
float x,y;
public:
void set( float a=0, float b=0 )
{
x=a;
y=b;
}
void show()
{
cout<<"点的坐标为:("<<x<<","<<y<<")"<<endl;
}
Point ( float a=0 , float b=0 )
{
x=a;
y=b;
}
friend float distance ( Point &p1 , Point &p2 ) ;
};
float distance ( Point &p1 , Point &p2 )
{
float x=p1.x-p2.x;
float y=p1.y-p2.y;
return sqrt(x*x+y*y);
}
int main(void)
{
Point p1(1,2),p2(1,4);
p1.show();
p2.show();
float s=distance(p1,p2);
return 0;
}
#include<cmath>
using namespace std;
class Point
{private:
float x,y;
public:
void set( float a=0, float b=0 )
{
x=a;
y=b;
}
void show()
{
cout<<"点的坐标为:("<<x<<","<<y<<")"<<endl;
}
Point ( float a=0 , float b=0 )
{
x=a;
y=b;
}
friend float distance ( Point &p1 , Point &p2 ) ;
};
float distance ( Point &p1 , Point &p2 )
{
float x=p1.x-p2.x;
float y=p1.y-p2.y;
return sqrt(x*x+y*y);
}
int main(void)
{
Point p1(1,2),p2(1,4);
p1.show();
p2.show();
float s=distance(p1,p2);
return 0;
}