코딩 연습/백준

[백준 1546] 평균

pansy0319 2019. 3. 11. 00:32
반응형

https://www.acmicpc.net/problem/1546



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>
using namespace std;
 
int main() {
    int n;
    cin >> n;
 
    int *score = new int[n];
    int max = 0;
    double total = 0;
    for (int i = 0; i < n; ++i){
        cin >> score[i];
        if (max < score[i]){
            max = score[i];
        }
        total += score[i];
    }
 
    total = (total / max) * 100;
 
    double average = total / n;
 
    cout << average << endl;
}
cs
반응형