본문 바로가기

[BOJ] - JAVA

[백준] 2562 : 최댓값 JAVA 풀이

import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.IOException;

public class Main{
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int idx = 0, max = -999;
        
        for(int i=0;i<9;i++){
            int val = Integer.parseInt(br.readLine());
            if(max<val){
                max = val;
                idx = i+1;
            }
        }
        System.out.printf("%d\n%d", max,idx);
    }
}