Let the Balloon Rise HDU水题

题意

让你统计字符串最多的那个串,并输出

分析

直接用map统计,不断更新最大值即可

代码

#include<iostream>
#include<algorithm>
#include<map>
#include<string>
using namespace std;
int main(){
	
    string s,ans;
	int n;
	//freopen("in.txt","r",stdin);
	while(cin>>n&&n){
		map<string,int> m;//映射 
		int maxn=0;
		while(n--){
			cin>>s;
			m[s]++;
			if(m[s]>maxn){
				maxn=m[s];
				ans=s;
			} 
		}
		cout<<ans<<endl;
	}
	return 0;
}
posted @ 2018-10-17 13:17  ChunhaoMo  阅读(78)  评论(0编辑  收藏  举报