728x90
반응형
2024.07.08기준 - 브론즈4
백준, BEAKJOON, BOJ, JAVA, 자바
풀이
이 문제는 간단하게 조건식을 이용하여 입력받은 값이 어디에 속하는지 출력하는 문제입니다.
- 레벨이 300이상이면 1을 출력합니다.
- 레벨이 300미만이고 275이상이면 2를 출력합니다.
- 레벨이 275미만이고 250이상이면 3을 출력합니다.
- 그 외에는 4를 출력합니다.
코드
package Main;
import java.io.*;
import java.util.*;
public 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));
StringBuilder sb = new StringBuilder();
int n = Integer.parseInt(br.readLine()); // 레벨의 개수
StringTokenizer st = new StringTokenizer(br.readLine());
int level;
while (n-- > 0) {
level = Integer.parseInt(st.nextToken()); // 레벨
if (level >= 300) { // 레벨이 300이상이면
sb.append(1);
} else if (300 > level && level >= 275) { // 레벨이 300미만이고 275이상이면
sb.append(2);
} else if (275 > level && level >= 250) { // 레벨이 275미만이고 250이상이면
sb.append(3);
} else { // 그 외
sb.append(4);
}
sb.append(" ");
}
bw.write(sb.toString());
bw.flush();
bw.close();
br.close();
}
}
728x90
반응형
'코딩테스트 일기 (BAEKJOON)' 카테고리의 다른 글
BAEKJOON / 백준 - JAVA 2153번 소수 단어 (0) | 2024.07.09 |
---|---|
BEAKJOON / 백준 - JAVA 14500번 테트로미노 (0) | 2024.07.08 |
BEAKJOON / 백준 - JAVA 1992번 쿼드트리 (0) | 2024.07.07 |
BAEKJOON / 백준 - JAVA 31907번 GIST 찍기 (0) | 2024.07.07 |
BAEKJOON / 백준 - JAVA 31880번 K512컵 개최! (0) | 2024.07.06 |