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
32
33
34
35
36
37
38
39
|
#include <iostream>
int main()
{
int loop = 0;
int loopMax = 0;
scanf("%d", &loopMax);
while (loopMax>loop)
{
int studentNum = 0;
scanf("%d", &studentNum);
float* scoreList = new float[studentNum];
float inputScore = 0.0f;
float sum = 0.0f;
float average = 0.0f;
int count = 0;
float result = 0.0f;
for (int i = 0; i < studentNum; i++)
{
scanf("%f", &inputScore);
scoreList[i] = inputScore;
sum += inputScore;
}
average = sum / studentNum; //평균 값
for (int i = 0; i < studentNum; i++)
{
if (scoreList[i] > average)
{
count++;
}
}
result = ((float)count / studentNum) * 100; // 백분율 구하기
printf("%.3f%%\n", result); //소수점 셋째자리 %.3f , %출력 -> %%
delete[] scoreList;
loop++;
}
return 0;
}
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 |
'프로그래밍 > 알고리즘' 카테고리의 다른 글
정수 N개의 합 (0) | 2019.10.11 |
---|---|
c++ 백분율,퍼센트 계산 (0) | 2019.09.03 |
백준 8958 OX퀴즈 (0) | 2019.09.03 |
백준 평균 1546 (0) | 2019.09.03 |
백준 3052 나머지 (0) | 2019.09.02 |