include iostream include conio include math using namespace std class

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
#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;
}