-
Notifications
You must be signed in to change notification settings - Fork 1
/
Problema_1043.cpp
48 lines (37 loc) · 952 Bytes
/
Problema_1043.cpp
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
/*
@autor: Victor E. B. Rodrigues;
@data: 23/06/2021;
@nome: Triângulo;
*/
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
double getAreaTrapezio(double& baseMaior, double& baseMenor, double& altura){
return (baseMaior + baseMenor)*altura/2.0;
}
double getPerimetroTriangulo(double& lado1, double& lado2, double& lado3){
return lado1+lado2+lado3;
}
double absAB(double& a, double& b){
if (a-b > 0)
return a-b;
return (a-b)*(-1);
}
bool formaTriangulo(double& lado1, double& lado2, double& lado3){
if(lado1 < lado2 + lado3 && lado1 > absAB(lado2, lado3))
return true;
return false;
}
int main() {
cin.tie(NULL);
cout.tie(NULL);
ios::sync_with_stdio(0);
double x, y, z;
cin >> x >> y >> z;
cout << setprecision(1) << fixed;
if(formaTriangulo(x, y, z))
cout << "Perimetro = " << getPerimetroTriangulo(x, y, z) << endl;
else
cout << "Area = " << getAreaTrapezio(x, y, z) << endl;
return 0;
}