mirea-projects/Second term/Industrial programming technologies/1/2.cpp
2024-09-24 02:22:33 +03:00

39 lines
821 B
C++
Executable File

#include <cmath>
#include <iostream>
using namespace std;
class Triangle {
public:
double a, b, c;
Triangle(double an, double bn, double cn) : a(an), b(bn), c(cn) {
if (!Triangle::exst_tr()) {
this->a = 3;
this->b = 4;
this->c = 5;
}
}
bool exst_tr();
void show();
double perimetr();
double square();
};
bool Triangle::exst_tr() {
return Triangle::perimetr() - max(max(this->a, this->b), this->c) * 2 > 0;
}
void Triangle::show() {
cout << "A = " << this->a << ", B = " << this->b << ", C = " << this->c << endl;
}
double Triangle::perimetr() {
return this->a + this->b + this->c;
}
double Triangle::square() {
double p = Triangle::perimetr() / 2;
return sqrt(p * (p - this->a) * (p - this->b) * (p - this->c));
}