Dev.baelanche

[백준 11292] 키 큰 사람 본문

Data Structure & Algorithm/PS - JAVA

[백준 11292] 키 큰 사람

baelanche 2019. 4. 27. 13:38
반응형

 

배열에 이름과 키를 담아 키가 최대값인 이름만 출력시키면 된다.

 

 

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        while(true) {
            int n = sc.nextInt();
            String s[][] = new String[n][2];
            if(n==0) break;
            float max = 0;
            for(int i=0; i<n; i++) {
                s[i][0] = sc.next();
                s[i][1] = sc.next();
                max = Float.parseFloat(s[i][1]) > max ? Float.parseFloat(s[i][1]) : max;
            }
            String name = "";
            for(int i=0; i<n; i++)
                if(Float.parseFloat(s[i][1]) == max)
                    name += s[i][0] + " ";
            System.out.println(name);
        }
    }
}
반응형

'Data Structure & Algorithm > PS - JAVA' 카테고리의 다른 글

[백준 1773] 폭죽쇼  (0) 2019.04.27
[백준 12813] 이진수 연산  (0) 2019.04.27
[백준 16236] 아기 상어  (0) 2019.04.23
[백준 11057] 오르막 수  (0) 2019.04.23
[백준 9251] LCS  (0) 2019.04.23
Comments