Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 구현
- array
- Stack
- dynamic programming
- geometry
- two pointers
- 코딩테스트
- Counting
- Math
- Binary Search
- hash table
- 자바
- SQL
- bit manipulation
- Tree
- simulation
- 코테
- Data Structure
- 파이썬
- Class
- Binary Tree
- sorting
- Number Theory
- database
- java
- greedy
- string
- Method
- implement
- Matrix
Archives
- Today
- Total
코린이의 소소한 공부노트
[백준 온라인 저지] 5073. 삼각형과 세 변 본문
- 입력: 각 줄에는 1,000을 넘지 않는 양의 정수 3개가 입력된다. 마지막 줄은 0 0 0이며 이 줄은 계산하지 않는다.
- 출력: 주어진 각 삼각형의 세 변의 길이에 따라 아래 중 1개를 출력한다.
1) Equilateral : 세 변의 길이가 모두 같은 경우
2) Isosceles : 두 변의 길이만 같은 경우
3) Scalene : 세 변의 길이가 모두 다른 경우
4) Invaild: 삼각형이 이루어지지 않을 경우
import java.io.*;
class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
String s = br.readLine();
while(!s.equals("0 0 0")){
String[] input = s.split(" ");
int a = Integer.valueOf(input[0]), b = Integer.valueOf(input[1]), c = Integer.valueOf(input[2]);
if(Math.abs(a-b)<c && c<(a+b)){
if(a==b){
if(a==c) bw.write("Equilateral\n");
else bw.write("Isosceles\n");
} else{
if(a==c || b==c) bw.write("Isosceles\n");
else bw.write("Scalene\n");
}
} else
bw.write("Invalid\n");
s = br.readLine();
}
bw.flush();
bw.close();
}
}
'코딩테스트 풀이 > JAVA' 카테고리의 다른 글
[LeetCode/Easy] 819. Most Common Word (0) | 2023.03.31 |
---|---|
[백준 온라인 저지] 14215. 세 막대 (0) | 2023.03.29 |
[백준 온라인 저지] 10101. 삼각형 외우기 (0) | 2023.03.29 |
[백준 온라인 저지] 9063. 대지 (0) | 2023.03.29 |
[백준 온라인 저지] 15894. 수학은 체육과목입니다. (0) | 2023.03.29 |