[백준/Java] 2562 : 최댓값

SEOP·2023년 6월 2일
0
post-custom-banner

import java.io.*;
import java.util.ArrayList;
import java.util.List;

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

        List<Integer> list = new ArrayList<>();

        for(int i = 0 ; i < 9 ; i++){
            list.add( Integer.parseInt( br.readLine() ) );
        }

        int max = list.get(0);

        for(int j = 1; j < list.size(); j++){
            if( max < list.get(j)){
                max = list.get(j);
            }
        }

        int index = list.indexOf(max) + 1;

        bw.write(String.valueOf(max));
        bw.newLine();
        bw.write(String.valueOf(index));
        bw.flush();
        bw.close();
    }
}
profile
응애 나 애기 개발자
post-custom-banner

0개의 댓글