[백준] 4344번 : 평균은 넘겠지 - Java(자바)

강재원·2022년 10월 29일
0

[코딩테스트] Java

목록 보기
161/200



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

import java.util.*;
public class Main {
    public static void main(String args[]) {
        Scanner s=new Scanner(System.in);
        int n=s.nextInt();
        for(int i=0;i<n;i++){
            int m=s.nextInt();
            int sum=0;
            int count=0;
            int arr[]=new int[m];
            for(int j=0;j<m;j++){
                arr[j]=s.nextInt();
                sum+=arr[j];
            }
            double ave=(double)sum/m;
            for(int j=0;j<m;j++){
                if(arr[j]>ave) count++;
            }
            System.out.format("%.3f%c\n",(double)count*100/m,'%');
        }
    }
}
profile
개념정리 & 문법 정리 & 알고리즘 공부

0개의 댓글