문제링크
https://www.acmicpc.net/problem/4344
나의코드
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.StringTokenizer;
public class Main{
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int testCase = Integer.parseInt(br.readLine());
StringTokenizer st;
for(int i = 0; i < testCase; i++){
st = new StringTokenizer(br.readLine()," ");
int num = Integer.parseInt(st.nextToken());
int[] arr = new int[num];
double sum = 0;
for(int j = 0; j < num; j++){
int score = Integer.parseInt(st.nextToken());
arr[j] = score;
sum = sum + score;
}
double mean = (sum / num);
double count = 0;
for(int j = 0; j < num; j++){
if(arr[j] > mean){
count ++;
}
}
System.out.printf("%.3f%%\n",count / num * 100);
}
}
}
'Baekjoon Online Judge' 카테고리의 다른 글
[BOJ] 백준 4673번: 셀프 넘버 (Java) (0) | 2023.03.14 |
---|---|
[BOJ] 백준 15596번: 정수 N개의 합 (Java) (0) | 2023.03.13 |
[BOJ] 백준 8958번: OX퀴즈 (Java) (0) | 2023.03.11 |
[BOJ] 백준 1546번: 평균 (Java) (0) | 2023.03.10 |
[BOJ] 백준 3052번: 나머지 (Java) (0) | 2023.03.09 |
댓글