题目:https://www.patest.cn/contests/pat-a-PRactise/1054
代码:
#include<cstdio> #include<cstring> #include<cstdlib> #include<cmath>#include<map>#include<string>#include<iostream>#include<algorithm> using namespace std; int main() { int n,m,temp; scanf("%d%d",&n,&m); map<int,int> s; for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ scanf("%d",&temp); if(s.find(temp)!=s.end())s[temp]++; else s[temp]=1; } } int k=0,max=0; for(map<int,int>::iterator i=s.begin();i!=s.end();i++){ if(i->second>max){ k=i->first; max=i->second; } } printf("%d/n",k); system("pause"); }
新闻热点
疑难解答