【map/STL】HDU1029Ignatius and the Princess IV
2017-09-06 21:49
267 查看
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1029
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin.sync_with_stdio(false);
while(cin>>n){
map<string,int>Map;
int cnt=(n+1)/2;
string ans;
string a;
for(int i=0;i<n;i++){
cin>>a;
Map[a]++;
if(Map[a]>=cnt) ans=a;
}
cout<<ans<<endl;
}
return 0;
}
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin.sync_with_stdio(false);
while(cin>>n){
map<string,int>Map;
int cnt=(n+1)/2;
string ans;
string a;
for(int i=0;i<n;i++){
cin>>a;
Map[a]++;
if(Map[a]>=cnt) ans=a;
}
cout<<ans<<endl;
}
return 0;
}
相关文章推荐
- STL中map用法详解(转)
- C++STL(vector,map,set,list)成员函数整理
- STL容器之map
- C++ STL编程 map
- STL中map用法详解
- (经典map)A - Hardwood Species(7.1.1)(利用STL中自带的排序功能编程的实验范例)
- STL中map按值(value)排序
- STL中map用法详解
- [STL]MAP
- c++ - In STL maps, is it better to use map::insert than []? - Stack Overflow
- STL中map用法详解
- STL中改变map的默认比较方式
- PowerOJ 2436: STL入门 unordered_map
- C++的STL中的map用法详解
- STL中map用法详解
- STL关联容器之map
- STL-map
- STL(四) map,set,deque
- stl map vector的删除
- STL中关联容器map的用法