728x90
import java.io.*;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws IOException {
// 백준 4344: "평균은 넘겠지"
Scanner sc = new Scanner(System.in);
//입력 변수
int testcase = sc.nextInt(); //테스트케이스 수
int[] arr;
for(int i = 0; i < testcase; i++) {
int c = sc.nextInt(); // 테스트케이스 수에 대입되는 학생의 수
arr = new int[c]; // 학생 수만큼의 배열을 미리 초기화
double sum = 0;
for (int j = 0; j < c; j++) {
int score = sc.nextInt(); // 점수 입력받기
arr[j] = score; // 각 학생 수에 맞는 점수 배열에 점수를 대입
sum += score; // 점수들의 합
}
double avg = (sum / c);
double count = 0;
// 평균 이상의 학생 수 구하기
for(int j = 0; j < arr.length; j++) {
if(arr[j] >avg) {
count += 1;
}
}
System.out.printf("%.3f%%\n", (count/c) * 100);
}
}
}
728x90
'알고리즘' 카테고리의 다른 글
[백준] 2884 알람시계 (Python) (0) | 2022.07.27 |
---|---|
[백준] 2884 알람시계 (Java) (0) | 2022.07.27 |
[백준] 4344 평균은 넘겠지 (Python) (0) | 2022.07.27 |
[백준] 1157 단어 공부 (Python) (0) | 2022.07.20 |
[백준] 2675 문자열 반복 (Python) (0) | 2022.06.09 |