Answers for "determine count of each element in the array using maps"

0

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; } 
Posted by: Guest on August-21-2021

Code answers related to "determine count of each element in the array using maps"

Browse Popular Code Answers by Language