ALGORITHM ๐ค/Baekjoon
๋ฐฑ์ค - 2562
daxx0ne
2023. 3. 23. 11:01
https://www.acmicpc.net/problem/2562
2562๋ฒ: ์ต๋๊ฐ
9๊ฐ์ ์๋ก ๋ค๋ฅธ ์์ฐ์๊ฐ ์ฃผ์ด์ง ๋, ์ด๋ค ์ค ์ต๋๊ฐ์ ์ฐพ๊ณ ๊ทธ ์ต๋๊ฐ์ด ๋ช ๋ฒ์งธ ์์ธ์ง๋ฅผ ๊ตฌํ๋ ํ๋ก๊ทธ๋จ์ ์์ฑํ์์ค. ์๋ฅผ ๋ค์ด, ์๋ก ๋ค๋ฅธ 9๊ฐ์ ์์ฐ์ 3, 29, 38, 12, 57, 74, 40, 85, 61 ์ด ์ฃผ์ด
www.acmicpc.net
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int[] a = new int[9];
int max = 0;
int num = 0;
for (int i = 0; i < 9; i++) {
a[i] = sc.nextInt();
max = a[i];
}
for (int i = 0; i < 9; i++) {
if (max < a[i]) {
max = a[i];
}
}
for (int i = 0; i < 9; i++) {
if (max == a[i]) {
num = i;
}
}
System.out.println(max);
System.out.println(num + 1);
}
}