您的位置:首页 > 其它

第四章作业4.21

2015-06-27 15:50 281 查看
#include<iostream>
#include<cmath>
#include<string>
using namespace std;
class point{
float x1,y1,x2,y2;
public:
point(float a1,float b1,float a2,float b2)
{
x1=a1;
x2=a2;
y1=b1;
y2=b2;
}
friend void dist(point *pp);
void show();
double dis;
};

void dist(point *pp)
{
pp->dis=sqrt((pp->x1-pp->x2)*(pp->x1-pp->x2)+(pp->y1-pp->y2)*(pp->y1-pp->y2));
}

void point::show()
{
cout<<"两点间的距离为:"<<dis<<endl;
}

int main()
{
point p1(0,0,3,4);
dist(&p1);
p1.show();
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: