알고리즘/SW Expert Academy

[SWEA] 1204. [S/W 문제해결 기본] 1일차 - 최빈수 구하기(D2) / C++

minari 2023. 11. 1. 12:37

https://swexpertacademy.com/main/code/problem/problemDetail.do

 

SW Expert Academy

SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!

swexpertacademy.com


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
#include <iostream>
using namespace std;
 
int scores[101];
 
int main()
{
    int T;
    cin >> T;
 
    for (int test_case = 1; test_case <= T; test_case++)
    {
        
        //점수마다 사람 수 배열 초기화
        memset(scores, 0sizeof(scores));
 
        for (int i = 0; i < 1000; i++)
        {
            int score;
            cin >> score;
 
            scores[score]++;
        }
 
        int Most = 0;
        int result = 0;
        for (int i = 1; i < 101; i++)
        {
            if (scores[i] >= Most)
            {
                result = i;
                Most = scores[i];
            }
        }
 
        cout << "#" << test_case << " " << result << "\n";
    }
 
    return 0;
}
cs