Scanner sc = new Scanner(System.in);
int []a = new int[9];
int cut = 0;
int max = 0;
for (int i = 0; i < 9; i++) {
a[i] = sc.nextInt();
if (max<a[i]) {
max = a[i];
cut++; // cut = i+1 로 해도된다 인덱스+1
}
}
System.out.println(max);
System.out.println(cut);
최소,최대 문제와 다르지 않은 문제이다.
최댓값만 구해주고 거기에 카운트만 넣어주면 된다.
'Study > algorithm' 카테고리의 다른 글
백준 자바 알고리즘 [나머지] (0) | 2020.05.02 |
---|---|
백준 자바 알고리즘 [숫자의 개수] (0) | 2020.04.30 |
백준 자바 알고리즘 [최소,최대] (0) | 2020.04.30 |
백준 알고리즘 세수 자바 (0) | 2020.04.28 |
백준 알고리즘 상근날드 자바 (0) | 2020.04.28 |