#include #include #include using namespace std ; void printFreq( string inputString ) { map mapObject1 ; for( char ch1 : inputString ) { if ( ch1 == ' ' ) continue ; if ( mapObject1.count( ch1 ) > 0 ) mapObject1[ch1] = mapObject1[ch1] + 1 ; else mapObject1[ch1] = 1 ; } for( pair p1 : mapObject1 ) cout << "( " << p1.first << " " << p1.second << " )" ; cout << endl ; } int main () { printFreq( "aabbcb" ) ; printFreq( "George Chuvalo" ) ; return 0; }