티스토리 뷰

반응형


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// 2068. 최대수 구하기
import java.util.Scanner;
 
public class Solution2068 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int T = sc.nextInt();
        for(int i=0; i<T; i++) {
            int max = 0;
            for(int j=0; j<10; j++) {
                int num = sc.nextInt();
                if(num > max)
                    max = num;
            }
            System.out.println("#"+(i+1)+" "+max);
            max = 0;
        }
    }
}
 

cs


> BestSolution

1
2
3
4
5
6
7
8
9
10
11
12
13
14
import java.util.*;
public class Solution {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int T = sc.nextInt();
        for(int i=1; i<=T; i++){
            int[] n = new int[10];
            for(int j=0; j<10; j++)
                n[j]=sc.nextInt();
            Arrays.sort(n);
            System.out.println("#"+i+" "+n[9]);
        }
    }
}
cs


반응형
댓글
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday