#include <iostream> #include <string> #include <map> using namespace std; void maxNumTimes(int a[], int len, int b[]) { map<int, int> mapData; int count = 0; for(int i = 0; i < len; i++) { mapData[a[i]]++; } //int max times int maxTimes = 0; map<int, int>::const_iterator it = mapData.begin(); while(it!= mapData.end()) { if(maxTimes < it->second) maxTimes = it->second; it++; } //int max num int maxNum = 0; map<int, int>::reverse_iterator re_it = mapData.rbegin(); while(re_it != mapData.rend()) { if (maxTimes == re_it->second) { if (maxNum < re_it->first) { b[0] = re_it->first; } b[1] = re_it->second; } re_it++; } }
云腾软件