jeongwon
[백준 JAVA] 2562번 - 최댓값 본문

나의 답안:
import java.io.BufferedReader;
import java.io.IOException; //BufferedReader
import java.io.InputStreamReader;
class Main{
public static void main(String[] args) throws IOException {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
int[] arr = new int[9];
for(int i=0; i<arr.length; i++)
arr[i]=Integer.parseInt(bf.readLine());
bf.close();
int n = 0;
int max=0;
for(int i=0; i<arr.length; i++) {
if(arr[i]>max) {
max=arr[i];
n=i+1; //i=0 부터 시작이므로 i+1
}
}
System.out.println(max+"\n"+n);
}
}'오늘의 문제' 카테고리의 다른 글
| [백준 JAVA] 3052번 - 나머지 (0) | 2022.05.27 |
|---|---|
| [백준 JAVA] 2577번 - 숫자의 개수 (0) | 2022.05.26 |
| [백준 JAVA] 10818번 - 최소, 최대 (0) | 2022.05.25 |
| [백준JAVA] 1110번 - 더하기 사이클 (0) | 2022.05.24 |
| [백준 JAVA] 10952번 - A+B - 5 (0) | 2022.05.24 |