/*
1三角形(10分)
题目内容:
设计表示平面坐标系上点的Point类,以及三角形Triangle类。要求如下:
(1)两个类里面都必须有构造函数;
(2)Triangle类里面的数据成员必须是Point类型的;
Triangle类里面含有能够判断三点是否能够构成三角形的成员函数。
输入格式:输入三个点的坐标x1、y1、x2、y2、x3、y3
输出格式:输出YES表示能构成三角形;NO表示不能构成三角形
输入样例:0 0 5.5 0 100 0
输出样例:NO
*/
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
class Point{
private:
double x;
double y;
public:
Point(double x,double y);
Point();
friend class Line;
};
Point::Point(){x=0.0,y=0.0;}
Point::Point(double x ,double y ):x(x),y(y){}
class Line{
private:
Point a;
Point b;
double distance;
public:
Line(Point &a,Point &b);
friend class Triangle;
};
Line::Line(Point &a,Point &b){
distance=sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
class Triangle{
private:
Point a;
Point b;
Point c;
public:
string isTriangle();
Triangle(Point a,Point b,Point c);
};
string Triangle::isTriangle(){
string str;
double d1,d2,d3;
d1=Line(a,b).distance;
d2=Line(a,c).distance;
d3=Line(b,c).distance;
str=(d1+d2>d3 && d1+d3>d2 && d2+d3>d1)?"YES":"NO";
cout<<str;
return str;
}
Triangle::Triangle(Point a,Point b,Point c):a(a),b(b),c(c){}
int main()
{ string isTriangle;
double x1,y1,x2,y2,x3,y3;
Point a,b,c;
cin>>x1>>y1>>x2>>y2>>x3>>y3;
isTriangle=Triangle(Point(x1,y1),Point(x2,y2),Point(x3,y3)).isTriangle();
return 0;
}