max를 1로 설정 후 주어진 숫자가 max보다 클 경우 max를 주어진 숫자로 재할당하면 쉽게 풀 수 있는 문제다.
import java.io.*;
public class Main{
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int index = 0;
int max = 0;
for(int i = 0; i < 9; i++) {
int num = Integer.valueOf(br.readLine());
if(num > max) {
max = num;
index = i + 1;
}
}
System.out.println(max);
System.out.println(index);
}
}