#include
#include
// Более правильная версия
class Triangle {
private:
size_t a;
size_t b;
size_t c;
auto validate_sides()->bool;
public:
Triangle(size_t a, size_t b, size_t c);
auto set_a(size_t num)->void;
auto set_b(size_t num)->void;
auto set_c(size_t num)->void;
auto get_a()->size_t;
auto get_b()->size_t;
auto get_c()->size_t;
auto get_square_using_heron()->double;
};
bool Triangle::validate_sides()
{
size_t max_side = std::max(a, std::max(b, c));
auto sides_sum = this->a + this->b + this->c;
if (max_side < sides_sum - max_side)
return true;
return false;
}
Triangle::Triangle(size_t a, size_t b, size_t c)
{
this->a = a;
this->b = b;
this->c = c;
}
auto Triangle::set_a(size_t num)->void
{
a = num;
}
auto Triangle::set_b(size_t num)->void
{
b = num;
}
auto Triangle::set_c(size_t num)->void
{
c = num;
}
auto Triangle::get_a()->size_t
{
return a;
}
auto Triangle::get_b()->size_t
{
return b;
}
auto Triangle::get_c()->size_t
{
return c;
}
auto Triangle::get_square_using_heron()->double
{
if (!validate_sides())
throw std::exception("Неправильные стороны, треугольник с такими сторонами не существует");
auto p = (this->a + this->b + this->c) / 2;
return sqrt(p * (p - this->a) * (p - this->b) * (p - this->c));
}
// Более простая версия
class Triangle2 {
private:
size_t a;
size_t b;
size_t c;
public:
Triangle2(size_t a, size_t b, size_t c);
void set_a(size_t num);
void set_b(size_t num);
void set_c(size_t num);
int get_a();
int get_b();
int get_c();
double get_square_using_heron();
};
Triangle2::Triangle2(size_t a, size_t b, size_t c)
{
this->a = a;
this->b = b;
this->c = c;
}
auto Triangle2::set_a(size_t num)->void
{
a = num;
}
auto Triangle2::set_b(size_t num)->void
{
b = num;
}
auto Triangle2::set_c(size_t num)->void
{
c = num;
}
int Triangle2::get_a()
{
return a;
}
int Triangle2::get_b()
{
return b;
}
int Triangle2::get_c()
{
return c;
}
double Triangle2::get_square_using_heron()
{
auto p = (this->a + this->b + this->c) / 2;
return sqrt(p * (p - this->a) * (p - this->b) * (p - this->c));
}
int main()
{
size_t a, b, c;
std::cin >> a >> b >> c;
Triangle2 mc(a, b, c);
std::cout
system("pause");
return 0;
}