프로그래밍-학습기록/코딩테스트
백준 온라인 저지 | 2562 | 배열: 최댓값
leesche
2020. 7. 27. 22:25
문제 (https://www.acmicpc.net/problem/2562)
나의 풀이
쉬웠다! 같은 숫자면 어떡할까? 라고 생각하던 찰나, 조건에 서로 다른 숫자라서 안심했다.
package baekjunOnlineJudge;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Bj_2562 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int[] numberList = new int[9];
int max = 0;
int maxLocation = 0;
for(int i=0; i<9; i++) {
numberList[i] = Integer.parseInt(br.readLine());
}
for(int i=0; i<9; i++) {
if(max < numberList[i]) {
max = numberList[i];
maxLocation = i+1;
}
}
System.out.println(max);
System.out.println(maxLocation);
}
}