#include <iostream>
#include <conio.h>
#include <math.h>
using namespace std;
class triangle_cl{
public:
int fCath, sCath, hypo;
triangle_cl(){}
~triangle_cl(){}
void calculate(int fSide, int sSide, int tSide){
if(fSide > sSide && fSide > tSide){
this->hypo = fSide;
this->fCath = sSide;
this->sCath = tSide;
}else if(sSide > fSide && sSide > tSide){
this->fCath = fSide;
this->hypo = sSide;
this->sCath = tSide;
}else{
this->fCath = fSide;
this->sCath = sSide;
this->hypo = tSide;
}
float calc_hypo = sqrt(fCath*fCath + sCath*sCath);
if(this->hypo == calc_hypo){
this->printData(1);
}else{
this->printData(0);
}
}
float getArea(){
float area = (this->fCath * this->sCath)/2;
return round(area*10)/10;
}
float getMedian(){
float median = this->hypo/2;
return round(median*10)/10;
}
float getHeight(){
float height = (this->fCath*this->sCath)/this->hypo;
return round(height*10)/10;
}
int getPerimetr(){
int perimetr = this->fCath+this->sCath+this->hypo;
return perimetr;
}
float getR_in(){
int perim = this->getPerimetr();
float fraction = ((perim-this->fCath)*(perim-this->sCath)*(perim-this->hypo))/perim;
float r_in = sqrt(fraction);
return round(r_in*10)/10;
}
float getR_out(){
float r_out = (sqrt(fCath*fCath + sCath*sCath))/2;
return round(r_out*10)/10;
}
void printData(int msg){
if(msg == 1){
cout << endl;
cout << "Katet 1 (AB): " << this->fCath << endl;
cout << "Katet 2 (BC): " << this->sCath << endl;
cout << "Gipotenyza (AC)" << this->hypo << endl;
cout << "Plowad': " << this->getArea() << endl;
cout << "Mediana: " << this->getMedian() << endl;
cout << "Vusota: " << this->getHeight() << endl;
cout << "Perimetr: " << this->getPerimetr() << endl;
cout << "Radiys vpisannoi okryjnosti: " << this->getR_in() << endl;
cout << "Radiys opisannoi okryjnosti: " << this->getR_out() << endl;
}else{
cout << endl << "Treygolnika s takimi storonami ne sywestvyet!";
}
}
};
int main(){
int fSide, sSide, tSide;
cout << "Vvedite storonu treygolnika" << endl << endl;
cout << "Storona 1: "; cin >> fSide;
cout << "Storona 2: "; cin >> sSide;
cout << "Storona 3: "; cin >> tSide;
triangle_cl *triangle = new triangle_cl();
triangle->calculate(fSide, sSide, tSide);
delete triangle;
getch();
return 0;
}