算法分析与设计之C++STL
2019-10-13 本文已影响0人
余生如意
C++ 迭代器 容器
#include<iostream>
#include<string>
#include<iterator>
#include<map>
using namespace std;
int main(){
int n;
while(cin>>n&&n)
{
map<string, int> Balloon;
string s;
for(int i=0;i<n;i++)
{
cin >> s;
Balloon[s]++;
}
int iMax = 0;
map<string,int>::iterator point,loc;
for(point = Balloon.begin();point!=Balloon.end();point++)
{
if(iMax<point->second)
{
iMax = point->second;
loc = point;
}
}
cout<<loc->first<<endl;
}
return 0;
}
#include<iostream>
#include<vector>
using namespace std;
void display(vector<int> &v);
int main(){
cout<<"Hello"<<endl;
int i;
vector<int> v,v2(10);
cout<<"v1 length:"<<v.size()<<endl;
cout<<"v2 length:"<<v2.size()<<endl;
v.push_back(111);
return 0;
}
void display(vector<int> &v)
{
}