말랑한 하루

[SW Expert Academy] 1984 중간 평균 값 구하기 [Java] 본문

문제풀이/SWexpert Academy

[SW Expert Academy] 1984 중간 평균 값 구하기 [Java]

지수는말랑이 2021. 1. 21. 21:55
반응형

[ 핵심풀이 ]

[ 핵심소스 ]

[ Java ]

import java.util.Scanner;

public class Solution {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int tc = sc.nextInt();
        for (int t = 1; t <= tc; t++) {
            int high = 0;
            int low = 2147483647;
            int sum = 0;
            for (int i = 0; i < 10; i++) {
                int temp = sc.nextInt();
                sum += temp;
                high = high > temp ? high : temp;
                low = low < temp ? low : temp;
            }
//          System.out.println((double)((sum-high-low)/8));
            System.out.println("#"+t+" "+Math.round((double)(sum-high-low)/8));
        }
        sc.close();
    }
}
반응형
Comments