#include<iostream>
#include<cmath>
using namespace std;
class Point{
public:
Point(int xx,int yy){
x=xx;
y=yy;
}
Point(Point &p);
int getX(){return x;}
int getY(){return y;}
~Point(){};
private:
int x,y;
};
Point::Point(Point &p){
x=p.x;
y=p.y;
}
class Triangle{
private:
Point p1,p2,p3;
int len;
int area;
public:
Triangle(Point &a,Point &b,Point &c);
~Triangle(){};
float getA();
float getB();
float getC();
float getlen();
float getarea();
};
Triangle::Triangle(Point &a,Point &b,Point &c):p1(a),p2(b),p3(c){}
float Triangle::getA(){
float _x,_y,a;
_x=p2.getX()-p3.getX();
_y=p2.getY()-p3.getY();
a=sqrt(_x*_x _y*_y);
return a;
}
float Triangle::getB(){
float _x,_y,b;
_x=p1.getX()-p3.getX();
_y=p1.getY()-p3.getY();
b=sqrt(_x*_x _y*_y);
return b;
}
float Triangle::getC(){
float _x,_y,c;
_x=p2.getX()-p1.getX();
_y=p2.getY()-p1.getY();
c=sqrt(_x*_x _y*_y);
return c;
}
float Triangle::getlen(){
float a,b,c;
len=a b c;
return len;
}
float Triangle::getarea(){
float _p,a,b,c;
_p=0.5*(a b c);
area=sqrt(_p*(_p-a) _p*(_p-b) _p*(_p-c));
return area;
}
int main()
{
Point p1(0,0);
Point p2(0,6);
Point p3(8,0);
Triangle tri(p1,p2,p3);
cout<<tri.getlen()<<endl;
cout<<tri.getarea()<<endl;
return 0;
}
求大神帮忙改正一下...实在不会...