평균은 넘겠지(4344)
과연 그럴까요?
문제
입력
출력
예제 입력
5
5 50 50 70 80 100
7 100 95 90 80 70 60 50
3 70 90 80
3 70 90 81
9 100 99 98 97 96 95 94 93 91예제 출력
2번째 시도
Last updated
과연 그럴까요?
5
5 50 50 70 80 100
7 100 95 90 80 70 60 50
3 70 90 80
3 70 90 81
9 100 99 98 97 96 95 94 93 91Last updated
40.000%
57.143%
33.333%
66.667%
55.556%import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int c = sc.nextInt();
int arr[];
for (int i = 0; i < c; i++) {
int n = sc.nextInt();
arr= new int[n];
double sum = 0;
for (int j = 0; j < n; j++) {
int value = sc.nextInt();
arr[j] = value;
sum += value;
}
double avg = sum/n;
double count = 0;
for (int k = 0; k < n; k++) {
if(arr[k] > avg){
count++;
}
}
System.out.printf("%.3f%%\n", (count/n)*100);
}
}
}import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
for(int i=0; i<n; i++){
int size = sc.nextInt();
int arr[] = new int[size];
int avg = 0;
for(int j=0; j<size; j++){
arr[j] = sc.nextInt();
avg+=arr[j];
}
int cnt=0;
for(int j=0; j<size; j++){
if(arr[j] > avg/size)
cnt++;
}
System.out.println(String.format("%.3f%%", (double)cnt/size*100));
}
}
}