코딩테스트/자바 문제풀이

[CLASS 1: 구현] 백준 2562 최댓값

승요나라 2024. 10. 1. 18:28

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();
    }
}