1. 程式人生 > >HDU 1004 Let the Balloon Rise

HDU 1004 Let the Balloon Rise

second div pre code namespace stream http return first

技術分享圖片

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<map>
 4 using namespace std;
 5 int n;
 6 string s;
 7 map<string,int>m;
 8 int main()
 9 {
10     while(scanf("%d",&n)&&n)
11     {
12         m.clear();
13         for(int i=1;i<=n;i++)
14         {
15             cin>>s;
16 m[s]++; 17 } 18 map<string,int>::iterator ans=m.begin(),it; 19 for(it=m.begin();it!=m.end();it++) 20 if(it->second>ans->second) 21 ans=it; 22 cout<<ans->first<<endl; 23 } 24 return 0; 25 }

HDU 1004 Let the Balloon Rise