#include<iostream>
#include<cmath>
using namespace std;
class point
{
public:
point(double a,double b)
{
x=a;
y=b;
}
void showpoint()
{
cout<<"output the point:";
cout<<"("<<x<<","<<y<<")"<<"\n";
}
friend void dist(point& a ,point& b);
private:
double x;
double y;
};
void dist(point& a,point& b)
{
double d=sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
cout<<"d="<<d<<endl;
}
int main()
{
point poi1(0,0);
poi1.showpoint();
point poi2(3,4);
poi2.showpoint();
dist(poi1,poi2);
return 0;
}
作业4.22
最新推荐文章于 2021-05-20 02:55:10 发布