본문 바로가기
category/백준 알고리즘 c++

백준 알고리즘 1546번 평균 c++

by 자운대고라니 2020. 12. 13.
반응형

요약 : 케이스 값 입력 후 값만큼 성적 입력, 모든 점수를 (점수/최고점)*100 로 바꾼다음 평균을 출력한다.


소스코드

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
#include <iostream>
#include <cstdio>
 
using namespace std;
 
int main(void) {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int C,num;
    float result = 0,array[1000= {0,};
    int max = -1;
    cin >> C;
    for(int i=0;i<C;i++) {
        cin >> num;
        array[i] = num;
        if(max<array[i]) max = array[i];
    }
    for(int i=0;i<C;i++) {
        result += (array[i]/max)*100;
    }
    cout << result/<< endl;
    return 0;
}
cs

정답 확인

반응형

댓글