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;
}
上一篇:Win10家庭版无法打开策略组问题


下一篇:@RequestParam,@PathParam,@PathVariable,@QueryParam注解的使用区别