c++, 백준 2592번 대표값
2022. 7. 11.
방법1 : 최빈값을 카운트 하기 위해 map 자료구조를 활용. #include using namespace std; int s, avg, maxret, maxcnt = -1; map m; int main(){ for(int i = 0; i > input; s += input; if(m.find(input) != m.end()){ m[input]++; } else{ m.insert({input, 1}); } } for(auto t : m){ if(t.second > maxcnt){ maxcnt = t.second; maxret = t.first; } } avg = s / 10; cout maxcnt){ maxcnt = counter[i]; maxre..