Study📚/백준

[백준] - #4344: 평균은 넘겠지

woo!na 2024. 5. 29. 22:23

문제 출처 : https://www.acmicpc.net/

 


#4344: 평균은 넘겠지 (언어 : Java11)


제출 답안

import java.util.*;
public class Main{
    public static void main(String[] args) {
		int interval = sc.nextInt();
		for(int i=0; i<interval; i++) {
			int num = sc.nextInt();
			int[] score = new int[num];
			int total = 0;
			for(int j=0; j<score.length; j++) {
				int temp = sc.nextInt();
				score[j] = temp;
				total += temp;
			}
			double avg = total*1.0/num;
			int count = 0;
			for(int j=0; j<score.length; j++) {
				if(avg < score[j]*1.0)
					count++;
			}
			avg = 100*1.0/num*count;
			System.out.printf("%.3f%%\n", avg);
		}
	}
}

comment

-