-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path1043.cpp
50 lines (37 loc) · 1.03 KB
/
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
49
50
// https://judge.beecrowd.com/en/problems/view/1043
/*
Time Complexity =>
Space Complexity =>
*/
#include <bits/stdc++.h>
using namespace std;
bool isTriangle(double, double, double);
double calculatePerimeter(double, double, double);
double calculateArea(double, double, double);
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
ifstream input("input.txt");
ofstream output("output.txt");
double a = 0, b = 0, c = 0;
cin >> a >> b >> c;
if (isTriangle(a, b, c)) {
cout << "Perimetro = " << fixed << setprecision(1)
<< calculatePerimeter(a, b, c) << endl;
} else {
cout << "Area = " << fixed << setprecision(1) << calculateArea(a, b, c)
<< endl;
}
return 0;
}
bool isTriangle(double x, double y, double z) {
if ((x + y) > z && (y + z) > x && (z + x) > y) {
return true;
}
return false;
}
double calculatePerimeter(double x, double y, double z) { return (x + y + z); }
double calculateArea(double x, double y, double z) {
return (0.5 * z * (x + y));
}