https://www.acmicpc.net/problem/4344


내 답안
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int C = s.nextInt();
for (int i=0; i<C; i++) {
int N = s.nextInt();
int[] score = new int[N];
float total = 0;
float avg = 0;
float cnt = 0;
for (int j=0; j<N; j++) {
score[j] = s.nextInt();
total += score[j];
}
avg = total/N;
for (int val : score) {
if (val>avg) cnt++;
}
float ratio = cnt/N*100;
System.out.printf("%.3f%%\n",ratio);
}
}
}
'Coding Test > 백준' 카테고리의 다른 글
[백준 8958번 - java ] OX퀴즈 (0) | 2021.11.13 |
---|---|
[백준 11654번 - java] 아스키 코드 (0) | 2021.11.12 |
[백준 1546번 - java] 평균 (0) | 2021.11.12 |
[백준 3052번 - java] 나머지 (0) | 2021.11.12 |
[백준 2577번 - java] 숫자의 개수 (0) | 2021.11.08 |