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也~第一次独立用map好开心 #include<iostream> #include<map> using namespace std; int main (){ int N,M; cin>>N>>M; while(N!=0&&M!=0){ map<int,int> m; map<int,int>::iterator iter; for(int i=0;i<N*M;i++){ int temp; cin>>temp; m[temp]++; } int max=0; int sec=0; int count=0; for(iter=m.begin();iter!=m.end();iter++){ if(iter->second>max){ max=iter->second; } } for(iter=m.begin();iter!=m.end();iter++){ if(iter->second>sec&&iter->second!=max){ sec=iter->second; } } for(iter=m.begin();iter!=m.end();iter++){ if(iter->second==sec)cout<<iter->first<<" "; } cout<<endl; cin>>N>>M; } //system("pause"); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator