C++ STL map A1054 The Dominant Color(20)

自闭症网瘾萝莉.ら 提交于 2020-01-17 11:40:06

 

 

#include <bits/stdc++.h>
#include<math.h>
#include <string>
using namespace std;
const int maxn = 480005;//最大学生人数
map<int,int> temp;
int main(){
    int m,n;
    scanf("%d%d",&m,&n);
    for(int i=0;i<n;++i){
        for(int j = 0;j<m;++j){
            int t;
            scanf("%d",&t);
            //map<int,int>::iterator it;
            if(temp.find(t) != temp.end()){
              temp[t]++;  
            }else{
                temp[t] = 1;
            }
        }
    }
    map<int,int>::iterator it;
    int max = 0;
    int result = 0;
    for(it = temp.begin();it != temp.end();++it){
        if(it->second > max){
            max = it->second;
            result = it->first;
        }
    }
    cout<<result<<endl;
    system("pause");
    return 0;
} 
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!