#include<iostream.h>//构造函数是进行初始化的
#include<math.h>
class point{
int x;
int y;
public:
point(int m,int n)//构造函数
{
x=m;y=n;
}
int setx()
{
cout<<"please input x:";
cin>>x;
return x;
}
int sety()
{
cout<<"please input y:";
cin>>y;
return y;
}
void show()
{
cout<<"point("<<x<<","<<y<<")"<<endl;
}
friend int point::getTriange(point p1,point p2,point p3);
};
class Triangle{
point p1;
point p2;
point p3;
public:
int getTriange(point p1,point p2,point p3)
{
return (sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y))+sqrt((p1.x-p3.x)*(p1.x-p3.x)+(p1.y-p3.y)*(p1.y-p3.y))+sqrt((p2.x-p3.x)*(p2.x-p3.x)+(p2.y-p3.y)*(p2.y-p3.y)));
}
void showc()//输出三个坐标
{
p1.show();
p2.show();
p3.show();
}
};
void main()
{
point p1(1,1);
point p2(2,2);
point p3(3,3);
//a.setx();
//a.sety();
p1.show();
p2.show();
p3.show();
Triangle A;//定义一个三角形变量A
A.getTriange();
A.showc();
}哪里出现错误了
红糖糍粑
相关分类