http://codeforces.com/problemset/problem/43/A
点击打开链接
上边是题目的链接。
自己用了很土很原始的数数方法AC了,,真水。。。还是得学学大佬们的套路。
http://blog.csdn.net/KEYboarderQQ/article/details/52614267
点击打开链接
利用map遍历; 原来map的迭代器是iterator
#include <bits/stdc++.h>
using namespace std;
typedef __int64 LL;
map<string,int>mp;
string ss,ans;
int main()
{
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
cin>>ss;
mp[ss]++;
}
map<string,int>::iterator it;
int tmp=0;
for(it=mp.begin();it!=mp.end();it++)
{
if(it->second>tmp)
{
tmp=it->second;
ans=it->first;
}
}
cout<<ans<<endl;
return 0;
}
2017年03月12日 22:01:06 书
转载请注明原文地址: https://ju.6miu.com/read-37446.html