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
|
public class Main {
public static void main(String[]args) {
Scanner scan=new Scanner(System.in);
int testcase=scan.nextInt();
for(int i=0;i<testcase;i++) {
int n=scan.nextInt();
int arr[]=new int[n];//n크기의 배열 생성
int total=0;
for(int j=0;j<n;j++) {
arr[j]=scan.nextInt();//배열 입력받음
total+=arr[j];//총합
}
double avg=(double)total/n;//평균구하기
int cnt=0;
for(int j=0;j<n;j++) {
if(arr[j]>avg)
cnt++;
}
float num=(float)cnt/n*100;
String str=String.format("%.3f", num);
System.out.println(str+"%");
}
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs |
'Algorithm > BOJ' 카테고리의 다른 글
[BOJ/C++]1463번 1로 만들기 (0) | 2020.07.28 |
---|---|
[BOJ/C++] 단계별로 풀어보기- 입출력과 사칙연산 (0) | 2020.05.27 |
[BOJ/Java]8958번 OX퀴즈 (0) | 2020.03.09 |
[BOJ/C++] 3052번 나머지 (0) | 2020.01.31 |
[BOJ/Java] 2794번 블랙잭 (0) | 2020.01.31 |
댓글