1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int[] arr = new int[9];
int max = 0;
int maxIndex = 0;
for(int i=0; i<arr.length; i++) {
arr[i] = scan.nextInt();
if(arr[i]>max) {
max = arr[i];
maxIndex = i+1;
// 최대값이 몇번째 자리인지(인덱스 번호 + 1)
}
}
System.out.println(max);
System.out.println(maxIndex);
}
}
|
cs |
'Algorithm > 백준' 카테고리의 다른 글
백준 3052 (나머지) (0) | 2022.06.28 |
---|---|
백준 2577 (숫자의 개수) (0) | 2022.06.27 |
백준 10818 (최소, 최대) (0) | 2022.06.27 |
백준 1110 (더하기 사이클) (0) | 2022.06.25 |
백준 2439 (별 찍기 - 2) (0) | 2022.06.24 |