BOJ 코딩테스트/Bronze
BOJ 10101번 : 삼각형 외우기 (Python, Java/구현/Bronze 4)
dev스카이
2024. 3. 21. 13:24
10101번: 삼각형 외우기
문제의 설명에 따라 Equilateral, Isosceles, Scalene, Error 중 하나를 출력한다.
www.acmicpc.net
설명
세 각의 크기가 모두 60이면, Equilateral
세 각의 합이 180이고, 두 각이 같은 경우에는 Isosceles
세 각의 합이 180이고, 같은 각이 없는 경우에는 Scalene
세 각의 합이 180이 아닌 경우에는 Error
를 출력하는 프로그램을 작성하시오.
Solution
Java
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a, b, c;
a = sc.nextInt();
b = sc.nextInt();
c = sc.nextInt();
if (a + b + c != 180) {
System.out.println("Error");
} else if (a != b && b != c && a != c) {
System.out.println("Scalene");
} else if (a != b || b != c || a != c) {
System.out.println("Isosceles");
}else{
System.out.println("Equilateral");
}
}
}
Python
a = int(input())
b = int(input())
c = int(input())
if a + b + c != 180:
print("Error")
elif a != b and b != c and a != c:
print("Scalene")
elif a != b or b != c or a != c:
print("Isosceles")
else:
print("Equilateral")