思想;用一个数组保存每个字符串出现的次数;其中为了能够用 该时数组与前边数组比较,设置一个结构数组能够寸字符串就 ok了;
AC代码;
#include <iostream>
#include <cstdio>
#include <cstring>
#include <map>
#include <algorithm>
#include <sstream>
#include <set>
#include <string>
#include <stack>
#include <vector>
using namespace std;
const int N = 10000;
typedef long long LL;
const int inf = 0x3f3f3f3f;
struct str{
char c[N];
}str[N];
int main()
{
LL t;
LL num[N];
while(cin>>t&&t)
{
getchar();
for(int i=0;i<t;i++)
{
cin>>str[i].c;
}
for(int i=0;i<t;i++)
{
int m=1;
for(int j=i+1;j<t;j++)
if(!strcmp(str[i].c,str[j].c))
m++;
num[i]=m;
}
LL maxn=num[0];
LL k=0;
for(int j=1;j <t;j++)
if(maxn<num[j])
{
maxn=num[j];
k=j;
}
cout<<str[k].c<<endl;
}
return 0;
}