Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

我发现没有人用map也~

Posted by howling at 2011-07-18 14:12:11 on Problem 2092
第一次独立用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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator