标签:tin float next find gre first ons roc problem
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 116867 Accepted Submission(s): 45783
1 #include<iostream> 2 #include<stdio.h> 3 #include<string> 4 #include<cstring> 5 #include<algorithm> 6 #include<set> 7 #include<vector> 8 #include<map> 9 10 using namespace std; 11 12 int main() 13 { 14 int n; 15 string co,ss; 16 map<string ,int>color; 17 while(cin>>n,n) 18 { 19 color.clear(); 20 for(int i = 1; i <= n; i++) 21 { 22 cin>>co; 23 color[co]++; 24 } 25 int max = 0; 26 for(map<string,int>::iterator iter = color.begin();iter!=color.end();iter++) 27 { 28 if(iter->second>max) 29 { 30 max = iter->second; 31 ss = iter->first; 32 } 33 } 34 cout<<ss<<endl; 35 36 } 37 return 0; 38 }
非map
1 #include<stdio.h> 2 #include<string.h> 3 int main() 4 { 5 int n,i,j,max; 6 char a[1010][18]; 7 while(scanf("%d",&n),n) 8 { 9 max=1; 10 int b[1005]; 11 for(i=1;i<=n;i++) 12 { 13 scanf("%s",&a[i]); 14 b[i]=1; 15 } 16 for(i=1;i<n;i++) 17 { 18 if(b[i]==0) 19 continue; 20 for(j=i+1;j<=n;j++) 21 { 22 if(strcmp(a[i],a[j])==0) 23 { 24 b[i]++; 25 b[j]=0; 26 } 27 } 28 } 29 for(i=2;i<=n;i++) 30 if(b[max]<b[i]) 31 max=i; 32 printf("%s\n",a[max]); 33 34 } 35 }
标签:tin float next find gre first ons roc problem
原文地址:http://www.cnblogs.com/Xycdada/p/6537370.html