#include "math.h" //平方根 double sqrt(double) 平方 double pow(double x,double y);
class Triangle
{
private:
Point p1;
Point p2;
Point p3;
public:
bool IsTriangle(Point p1,Point p2,Point p3); //判断
bool IsTriangle(); //重载
float GetLengh(Point p1,Point p2); //A B 距离
float GetArea(); //面积
float GetTotalLen(); //周长
public:
Triangle(Point x1,Point x2,Point x3) {p1=x1;p2=x2;p3=x3} //初始化
}
float Triangle::GetArea()
{//面积 (1/4)√[(a+b+c)(a+b-c)(a+c-b)(b+c-a)
float a,b,c;
a = GetLengh(p1,p2);
b = GetLengh(p2,p3);
c = GetLengh(p3,p1);
return (float)sqrt((a+b+c)(a+b-c)(a+c-b)(b+c-a))/4
}
float Triangle::GetTotalLen()
{
return GetLengh(p1,p2)+GetLengh(p2,p3)+GetLengh(p3,p1);
}
float Triangle::GetLengh(Point p1,Point p2)
{ //公式 ∣AB∣=√[(X1-X2)^2+(Y1-Y2)^2
return (float)sqrt( pow(p1.x-p2.x)+pow(p1.y-p2.y) );
}
bool Triangle::IsTriangle(Point p1,Point p2,Point p3)
{
if(GetLength(p1,p2)>p3&&GetLength(p2,p3)>p1&&GetLenght(p1,p3)>p2)
return ture;
else
return false;
}
bool Triangle::IsTriangle()
{
return IsTriangle(p1,p2,p3);
}
//测试
Triangle my1(7,8,9);
if(my1.IsTriangle())
puts("yes");
else
puts("No");