CODEFORCES,43A Football

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-NC-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/I_love_you_dandan/article/details/61654861

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 书

猜你喜欢

转载自blog.csdn.net/I_love_you_dandan/article/details/61654861