백준 자바 4344 평균은 넘겠지

·2022년 12월 20일
0

백준

목록 보기
13/16
post-thumbnail

이전 문제처럼 String 배열로 받으려했던 나를 매우 쳐라.. String으로 받아서 어? 된느거 아닌가 잠만 아 시바 이러면 다 숫자로 바꿔야되니까 똑같네 네 취소할게요

public class Num4344 {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int[] score;
    int count = scanner.nextInt(); // 몇개의 그룹이 있는지

    for (int i = 0; i < count; i++) { 
      int number = scanner.nextInt(); // 그 그룹 하나당 몇명이 있는지
      score = new int[number];
      double sum = 0;
      for (int j = 0; j < number; j++) {
        int grade = scanner.nextInt();
        score[j] = grade;
        sum += grade;
      }
      double average = sum / number;
      double over = 0;
      for (int k = 0; k < number; k++) {
        if (score[k] > average) {
          over++;
        }
      }
      System.out.printf("%.3f%%%n", over / number * 100);
    }
  }
}
profile
어?머지?

0개의 댓글