标签:华为
#include<iostream> #include<map> #include<vector> #include<algorithm> using namespace std; int main(int argc, char *argv[]) { int num[]={1,1,3,4,4,4,9,9,9,10}; int len=sizeof(num)/sizeof(int); map<int,int>m; vector<int>vec; for(int i=0;i<len;++i) m[i]=0; int cnt=0; for(int i=0;i<len;++i){ m[num[i]]++; if(m[num[i]]>cnt) cnt=m[num[i]]; } for(map<int,int>::iterator it=m.begin();it!=m.end();++it) { if(it->second==cnt) vec.push_back(it->first); } sort(vec.begin(),vec.end()); for(vector<int>::iterator it=vec.begin();it!=vec.end();++it) { cout<<*it<<endl; } return 0; }
标签:华为
原文地址:http://blog.csdn.net/wdkirchhoff/article/details/42388639