Notice
Recent Posts
Recent Comments
Link
«   2025/12   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
Tags more
Archives
Today
Total
관리 메뉴

jeongwon

[백준 JAVA] 2562번 - 최댓값 본문

오늘의 문제

[백준 JAVA] 2562번 - 최댓값

jeongwon_ 2022. 5. 25. 12:32

 

나의 답안:

import java.io.BufferedReader;
import java.io.IOException;		//BufferedReader
import java.io.InputStreamReader;

class Main{
	public static void main(String[] args) throws IOException   {
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		
		int[] arr = new int[9];
        
		for(int i=0; i<arr.length; i++)
		arr[i]=Integer.parseInt(bf.readLine());	
        
		bf.close();		
		
		int n = 0;
		int max=0;
		for(int i=0; i<arr.length; i++) {
			if(arr[i]>max) {
				max=arr[i];
				n=i+1;		//i=0 부터 시작이므로 i+1
			}
		}
		System.out.println(max+"\n"+n);
		}				
	}