1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
#include <iostream>
#include <map>
#include <algorithm>
#include <utility>
int main()
{
const int a[] = { 175, 167, 160, 164, 183, 187, 188, 179, 176, 175,
169, 175, 176, 178, 165, 160, 173, 165, 187, 178 };
std::map<int, int> m;
for ( auto it = std::begin( a ); it != std::end( a ); ++it )
{
++m[*it];
}
std::for_each( m.begin(), m.end(),
[]( std::pair<const int, int> x )
{ std::cout << x.first << ' ' << x.second << std::endl; } );
return 0;
}
|