본문 바로가기
Beakjoon&프로그래머스/Java

[백준/Java] 4299번 최댓값

by 현장 2022. 4. 16.

-Code

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int[] nums = new int[9];
        int max = 0;
        int index = 0;

        for (int i = 0; i < 9; i++) {
            nums[i] = sc.nextInt();
            if (nums[i] > max){
                max = nums[i];
                index = i + 1;
            }
        }
        System.out.println(max);
        System.out.println(index);
    }
}