Description
This year, they decide to leave this lovely job to you.
Input
A test case with N = 0 terminates the input and this test case is not to be processed.
Output
Sample Input
5 green red blue red red 3 pink orange pink 0
Sample Output
redpink
map容器存储
#include<stdio.h> #include<string.h> #include<math.h> #include<stdlib.h> #include<ctype.h> #include<iostream> #include<string> #include<algorithm> #include<set> #include<vector> #include<queue> #include<map> #include<numeric> #include<stack> #include<list> const int INF=1<<30; const int inf=-(1<<30); using namespace std; map<string,int>m; int main() { int n; string s,ss; while(cin>>n,n) { int max=inf; for(int i=0; i<n; i++) { cin>>s; m[s]++; if(m[s]>max) { max=m[s]; ss=s; } } cout<<ss<<endl; } return 0; }