杭电OJ-1004

#include <iostream>
#include <string>
#include <functional>
#include <map>
using namespace std;
int main(void){
	int n;
	string str;
	while(scanf("%d", &n) != EOF){
		map<string, int> myMap;
		map<int, string, greater<int> > myMap2;
		if(n == 0){  //如果为0,则跳至下一个循环
			continue;
		}
		for(int i = 0; i < n; i++){
			cin >> str;
			myMap[str]++;
		}
		map<string, int>::iterator  it = myMap.begin();
		for(; it != myMap.end(); it++){
			myMap2[it->second] = it->first;  //转换
		}
		cout << (myMap2.begin())->second << endl;
	}
	
	return 0;
}

猜你喜欢

转载自blog.csdn.net/weixin_42067873/article/details/106886168