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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
#include <iostream>
int GetMaxScore(int maxScore , float list[] , int size)
{
maxScore = 0;
for (int idx = 0; idx < size; idx++)
{
if (list[idx] > maxScore)
{
maxScore = list[idx];
}
}
return maxScore;
}
float GetAverage(float average, int score, float list[], int size)
{
for (int idx = 0; idx < size; idx++)
{
list[idx] = list[idx] / (float)score * 100;
}
float result = 0;
for (int idx = 0; idx < size; idx++)
{
result += list[idx];
}
average = result / size;
return average;
}
int main()
{
int size = 0;
int input = 0;
int maxscore = 0;
float average = 0.0f;;
scanf("%d", &size);
float *list = new float[size];
for (int idx = 0; idx < size; idx++)
{
scanf("%d", &input);
list[idx] = input;
}
maxscore = GetMaxScore(maxscore, list, size);
average = GetAverage(average, maxscore, list, size);
printf("%f\n", average);
delete[] list;
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 |
'프로그래밍 > 알고리즘' 카테고리의 다른 글
백준 4344 평균은 넘겠지 (0) | 2019.09.03 |
---|---|
백준 8958 OX퀴즈 (0) | 2019.09.03 |
백준 3052 나머지 (0) | 2019.09.02 |
백준 2577 숫자의 개수 (0) | 2019.09.02 |
백준 2920 음계 (0) | 2019.08.30 |