PAT A1054 the dominent color (20)

来源:互联网 发布:basic和vb 编辑:程序博客网 时间:2024/05/22 15:33
#include<cstdio>
#include<algorithm>
#include<map>
using namespace std;
int main(){
int m,n;
map<int,int> mp;
scanf("%d%d",&m,&n);
int i,j;
int px,maxpx,maxnum=0;
for(i=0;i<n;i++){
for(j=0;j<m;j++){
scanf("%d",&px);
if(mp.count(px)==0) mp[px]=0;
mp[px]++;
if(mp[px]>maxnum){
maxnum=mp[px];
maxpx=px;
}
}
}
printf("%d\n",maxpx);
system("pause");
return 0;
}
0 0