Notice
Recent Posts
Recent Comments
Link
«   2024/12   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

main

[백준-4344번/Java] 평균은 넘겠지 본문

Algorithm

[백준-4344번/Java] 평균은 넘겠지

1984 2022. 11. 10. 18:20
import java.util.Scanner;

public class Main {

	static void average(int[] arr, int avrg) {
		int cnt = 0;
		for (int i : arr) {
			if (i > avrg) {
				cnt++;
			}
		}
		System.out.printf("%.3f%%\n", (double) cnt / arr.length * 100);
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		for (int i = 0; i < N; i++) {

			int N2 = sc.nextInt();
			int sum = 0;
			int[] numbers = new int[N2];
			for (int j = 0; j < N2; j++) {
				int num = sc.nextInt();
				sum += num;
				numbers[j] = num;
			}
			average(numbers, sum / N2);
		}

		sc.close();
	}

}
728x90

'Algorithm' 카테고리의 다른 글

[백준-1152번/Java] 단어의 개수  (0) 2022.11.10
[백준-1157번/Java] 단어공부  (0) 2022.11.10
[백준-8959번/Java] OX 퀴즈  (0) 2022.11.10
[백준-3052번/Java] 나머지  (0) 2022.11.10
[백준-15552번/Java] 빠른 A+B  (0) 2022.11.10
Comments