determine count of each element in the array using maps
#include<bits/stdc++.h> using namespace std; int main(){ map<int, int> m; int arr[] = {0,2,1,3,3,4,10,55,10}; int size = sizeof(arr)/sizeof(arr[0]); for(int i = 0 ; i < size ; i++){ m[arr[i]]++; } map<int,int>::iterator itr; for(itr = m.begin() ; itr != m.end() ; itr++){ cout<<"Element: "<<(*itr).first<<endl; cout<<"Count: "<<(*itr).second<<endl; } return 0; }