#include<iostream>
#include<cmath>
using namespace std;
class point{
private:
int x;
int y;
public:
point(int a,int b)
{
x=a;
y=b;
}
void show();
friend void dist(point& a,point& b);
};
void point::show()
{
cout<<"输出该点坐标:"<<"("<<x<<","<<y<<")"<<endl;
}
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<<endl;
}
int main()
{
point p1(4,5);
p1.show();
point p2(7,8);
p2.show();
dist(p1,p2);
return 0;
}
作业 4.22
最新推荐文章于 2024-05-21 15:37:11 发布