2562번: 최댓값
https://www.acmicpc.net/problem/2562
# 코드
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int max = -1;
int max_loc = -1;
int[] arr = new int[9];
for (int i = 0; i < 9; i++) {
arr[i] = Integer.parseInt(br.readLine());
if (max < arr[i]) {
max = arr[i];
max_loc = i;
}
}
System.out.println(max);
System.out.println(max_loc + 1);
br.close();
}
}
'코딩테스트 > 자바 문제풀이' 카테고리의 다른 글
[CLASS 1: 구현] 백준 2675 문자열 반복 (1) | 2024.10.03 |
---|---|
[CLASS 1: 구현] 백준 10818 최소, 최대 (1) | 2024.10.02 |
[CLASS 1: 구현] 백준 11720 숫자의 합 (0) | 2024.09.30 |
[그리디] 백준 16953 A→B (0) | 2024.08.30 |
[그리디] 백준 20115 에너지 드링크 (0) | 2024.08.29 |