标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 94691 Accepted Submission(s): 36162
#include<iostream> #include<cstdio> #include<string.h> using namespace std; int main() { int n,l; char a[1200][20],c[1200][20]; int b[1200]; while(~scanf("%d",&n)) { if (n==0) break; memset(a,0,sizeof(a)); memset(c,0,sizeof(c)); memset(b,0,sizeof(b)); l=1; getchar(); for (int i=0;i<n;i++) { gets(a[i]); } strcpy(c[0],a[0]); b[0]=1; //puts(""); //printf("%s\n",c[0]); //printf("%s\n",a[1]); for (int i=1;i<n;i++) { for (int j=0;j<l;j++) { if (strcmp(a[i],c[j])==0) { //cout<<"sss"<<endl; //cout<<i<<endl; //printf("%s\n",a[i]); //printf("%s\n",c[j]); b[j]++; break; } if (j==l-1) { strcpy(c[l],a[i]); b[l]++; l++; break; //c[l]=a[i]; //printf("%s\n",a[i]); //printf("%s\n",c[l]); //l++; } } } // for (int o=0;o<5;o++) //printf("%d ",b[o]); //puts(""); l++; //printf("%d\n",l); int flag=0,k,temp=0; for ( k=0;k<l;k++) { //cout<<"ssss"<<endl; if (b[k]>flag) { //cout<<"sss"<<endl; flag=b[k]; temp=k; //cout<<k<<endl; } } //printf("%d\n",flag); printf("%s\n",c[temp]); //puts(""); } return 0; }
标签:
原文地址:http://www.cnblogs.com/xfjy/p/4991245.html