#include #include #include using namespace std; class triangle { public: triangle(); triangle(double x1_, double y1_, double x2_, double y2_, double x3_, double y3_) { x1 = x1_; y1 = y1_; x2 = x2_; y2 = y2_; x3 = x3_; y3 = y3_; a = length(x1, y1, x2, y2); b = length(x2, y2, x3, y3); c = length(x3, y3, x1, y1); } void operator+(float*); double length(double, double, double, double); float medianatoQ(float,float,float); float medianatoW(float,float,float); float medianatoE(float,float,float); bool isRight(); double GetLen(int); private: double x1, y1; double x2, y2; double x3, y3; double a, b, c; }; double triangle::length(double x1_, double y1_, double x2_, double y2_) { return sqrt((x2_ - x1_) * (x2_ - x1_) + (y2_ - y1_) * (y2_ - y1_)); } /* bool triangle::isRight() { if ((sqrt(a * a + b * b) == c) || (sqrt(a * a + c * c) == b)) return true; return false; } */ double triangle::GetLen(int k) { double arr[3] = {a, b, c}; return arr[k - 1]; } float triangle::medianatoQ(float q,float w,float e){ return 0.5*sqrt((2*w*w)+(2*e*e)-(q*q));} float triangle::medianatoW(float q,float w,float e){ return 0.5*sqrt((2*q*q)+(2*e*e)-(w*w));} float triangle::medianatoE(float q,float w,float e){ return 0.5*sqrt((2*q*q)+(2*w*w)-(e*e));} int main() { triangle trg(1.0, 0.0, 4.0, 1.0, 1.0, 1.0); float q,w,e; q=trg.GetLen(1); w=trg.GetLen(2); e=trg.GetLen(3); std::cout<<"a:"<