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
#include<iostream>
#include<vector>
#include<string>
using namespace std;
 
int main(void) {
    int N;
    int s;
    cin >> N;                                //테스트수 입력
    vector<double> result(N);                //5번의 결과
    for (int i = 0; i < N; i++) {            
        cin >> s;                            //학생 수
        vector<double> arr(s);                
        for (int j = 0; j < s; j++) {
            cin >> arr[j];                    //학생의 점수
            result[i] += arr[j];            //점수 총합저장    
        }
        result[i] =result[i]/(double)s;        //평균
        int count = 0;                
        for (int k = 0; k < s; k++) {
            if (arr[k] > result[i]) count++;    //평균보다 넘으면 +1
        }
        result[i] = (double)count / (double)s;    // 평균넘은학생수/전체학생수
    }
    for (int k = 0; k < N; k++) {
        printf("%.3lf", result[k]*100);            //*100을 하면 퍼센테이지
        cout << "%\n";
    }
}
 
cs


문제 출처:https://www.acmicpc.net/problem/4344


문제 피드백,질문 댓글로 부탁드려요~!



'알고리즘 > BAEKJOON' 카테고리의 다른 글

백준 10451번 순열 사이클  (0) 2018.11.08
백준 1718번 암호  (0) 2018.11.06
백준 1972번 놀라운 문자열  (0) 2018.11.06
백준 1411번 비슷한 단어  (0) 2018.11.01
백준 10545번 뚜기뚜기메뚜기  (0) 2018.11.01

+ Recent posts