به صورت عادی پیمایش کنید.
#include <iostream>
#include <map>
#include <vector>
using namespace std;
int main()
{
std::vector<int> list= {5,2,7,5,1,2,2} ;
std::map<int,int> values;
for (int i=0; i < list.size();i++){
if (values.find(list[i]) != values.end())
values[list[i]]++;
else values[list[i]] = 1;
}
for(auto it = values.begin(); it != values.end(); it++)
cout << it->first << "," << it->second << endl;
return 0;
}