#include<iostream>
#include<string>
using namespace std;
class point
{
public:
point(double a,double b)
void showpoint(point &c)
friend void dist(point& a ,point& b);
private:
double x;
double y;
};
point::point(double a,double b)
{
x=a;
y=b;
}
void point::showpoint(point &c)
{
cout<<"output the point:";
cout<<"c("<<x<<","<<y<<")"<<"\n";
}
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(4,4);
poi1.showpoint(point &c);
point poi2(5,4);
poi2.showpoint(point &c);
dist(poi1,poi2);
return 0;
}
4.22
最新推荐文章于 2024-04-22 23:56:04 发布