题目:http://vj.bit-studio.cn/contest/169126#problem/A

方法:map

#include<iostream>
#include<map>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<string.h>
using namespace std;
int main()
{
    int n;
    while (scanf("%d",&n))
    {
        if (n == 0)break;
        map<string, int>clo;
        for (int i = 0;i < n; i++)
        {
            bool flag = true;
            string temp;
            cin >> temp;
            map<string, int>::iterator iter;
            for (iter = clo.begin(); iter != clo.end(); iter++)
            {
                if (iter->first == temp)
                {
                    iter->second++;
                    flag = false;
                    break;
                }
            }
            if (flag)
            {
                clo[temp] = 1;
            }
        }
        map<string, int>::iterator ite;
        int max = 0;
        string max_ = "null";
        for (ite = clo.begin(); ite != clo.end(); ite++)
        {
            if (ite->second > max)
            {
                max = ite->second;
                max_ = ite->first;
            }
        }
        cout << max_ << endl;
    }
}