Notice
Recent Posts
Recent Comments
ยซ   2024/09   ยป
์ผ ์›” ํ™” ์ˆ˜ ๋ชฉ ๊ธˆ ํ† 
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
Tags more
Archives
Today
Total
๊ด€๋ฆฌ ๋ฉ”๋‰ด

๐ŸŒฒ์ž๋ผ๋‚˜๋Š”์ฒญ๋…„

Q4344 ํ‰๊ท ์€ ๋„˜๊ฒ ์ง€ ๋ณธ๋ฌธ

์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋ฌธ์ œํ’€์ด

Q4344 ํ‰๊ท ์€ ๋„˜๊ฒ ์ง€

JihyunLee 2019. 3. 26. 17:01
๋ฐ˜์‘ํ˜•

Q4344 ํ‰๊ท ์€ ๋„˜๊ฒ ์ง€



๊ฐ„๋‹จํ•˜๊ฒŒ ๋ฐฐ์—ด์„ ์ด์šฉํ•ด์„œ ๋ฌธ์ œ๋ฅผ ํ’€์—ˆ๋‹ค.



package problem;
//๋Œ€ํ•™์ƒ ์ƒˆ๋‚ด๊ธฐ๋“ค์˜ 90%๋Š” ์ž์‹ ์ด ๋ฐ˜์—์„œ ํ‰๊ท ์€ ๋„˜๋Š”๋‹ค๊ณ  ์ƒ๊ฐํ•œ๋‹ค. ๋‹น์‹ ์€ ๊ทธ๋“ค์—๊ฒŒ ์Šฌํ”ˆ ์ง„์‹ค์„ ์•Œ๋ ค์ค˜์•ผ ํ•œ๋‹ค.
import java.util.*;
public class Q4344 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int num = scan.nextInt();
for(int i=0; i<num; i++) {
int temp2 = scan.nextInt();
int[] arr = new int[temp2];
int count=0;
float sum=0;
float average=0;
//๋ชจ๋“ ๊ฐ’์„ ์–ด๋ ˆ์ด์— ๋‹ด๊ณ  ์ „์ฒดํ•ฉ์„ ๊ตฌํ•œ๋‹ค.
for(int j=0; j<temp2; j++) {
arr[j] = scan.nextInt();
sum += arr[j];
}
average = sum/temp2;
for(int j=0; j<temp2; j++) {
if(arr[j]>average) {
count++;
}
}
float ans = ((float)count/(float)temp2)*100;
System.out.format("%.3f",ans);
System.out.print("%\n");
}
}
}


๋ฐ˜์‘ํ˜•