Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
不用排序,map水过#include<stdio.h> #include<algorithm> #include<iostream> #include<map> using namespace std; map<int,int>mp; map<int,int >::iterator it; int main() { //freopen("in.txt","r",stdin); int m,n; while(scanf("%d%d",&m,&n)!=EOF) { if(n==0&&m==0) break; mp.clear(); int num; for(int i=0;i<n*m;i++) { scanf("%d",&num); mp[num]++; } int arr[10001]; int cnt=0; for(it=mp.begin();it!=mp.end();it++) arr[cnt++]=it->second; sort(arr,arr+cnt); for(it=mp.begin();it!=mp.end();it++) { if(it->second==arr[cnt-2]) printf("%d ",it->first); } printf("\n"); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator