백준 #2562번 최댓값

jhj·2024년 2월 18일

백준 JAVA

목록 보기
379/583
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int[] a = new int[9];
		for(int i = 0; i < a.length; i++) {
			a[i] = sc.nextInt();
		}
		
		int max = a[0];
		int maxIndex = 1;
		
		for(int i = 1; i < a.length; i++) {
			if(max < a[i]) {
				max = a[i];
				maxIndex = i + 1;
			}
		}
		
		System.out.println(max);
		System.out.println(maxIndex);
		sc.close();
	}
}
profile
개발자를 꿈꾸는

0개의 댓글