백준
백준 5073 - 삼각형과 세 변(C++)
공대생의 잡다한 사전
2023. 12. 9. 23:58
문제 링크입니다. https://www.acmicpc.net/problem/5073
5073번: 삼각형과 세 변
각 입력에 맞는 결과 (Equilateral, Isosceles, Scalene, Invalid) 를 출력하시오.
www.acmicpc.net


주어진 3변을 이용해, 어떤 삼각형인지 판별하는 문제입니다.
삼각형이 성립하는 조건을 유의해서 풀어주면 됩니다.
자세한 것은 코드를 참고해주세요.
#define _CRT_SECURE_NO_WARNINGS
#include <cstring>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstdio>
#include <string>
using namespace std;
int x, y, z;
int main() {
cin.tie(0);
cout.tie(0);
while(1){
int sum = 0, maxi = 0;
cin >> x >> y >> z;
sum = x + y + z;
maxi = max(x, y);
maxi = max(maxi, z);
if(x == 0 && y == 0 && z == 0) break;
if(maxi >= sum - maxi){
cout << "Invalid" << "\n";
continue;
}
if(x == y && y == z) cout << "Equilateral";
else if(x != y && y != z && x != z) cout << "Scalene";
else cout << "Isosceles";
cout << "\n";
}
return 0;
}

질문 및 조언은 댓글을 남겨주세요.