백준/기하
5073: 삼각형과 세 변 / C++
Koalitsiya
2023. 3. 21. 18:12
문제
풀이
일단 주어진 케이스가 삼각형의 조건을 만족하는지 검사하고 이후 위 조건에 따라 출력한다.
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
int x, y, z;
while (1) {
cin >> x >> y >> z;
if (x == 0 && y == 0 && z == 0)
break;
int sides[3] = { x,y,z };
sort(sides, sides + 3);
if (sides[2] >= sides[0] + sides[1]) {
cout << "Invalid\n";
continue;
}
if (x == y && x == z && y == z) {
cout << "Equilateral\n";
continue;
}
if (x == y || x == z || y == z) {
cout << "Isosceles\n";
continue;
}
cout << "Scalene\n";
}
return 0;
}