#include <fstream>
#include <cstdlib>
#include <string>
#include <sstream>
#include <iostream>
#include <map>
#include <set>

using namespace std;

template <typename T> T from_string(const string & s) {
	T res;
	istringstream tmp(s);
	tmp >> res;
	return res;
}

int main()
{
	ofstream o("hi.txt");
	for (int i = 0; i < 1000; i++)
	{
		o << (char)('a'+(rand()%26)) 
			<< "," << (int)(1 +(rand()%1000)) 
			<< ',' << (rand()/(float)RAND_MAX)
			<< endl;
	}
	o.close();

	ifstream inp("hi.txt");
	string line;

	map<char, int> m;
	set<int> my_set;
	while (std::getline(inp, line)) {
		//cout << line << endl;
		istringstream i(line);
		string notComma;
		getline(i, notComma, ',');
		char c = from_string<char>(notComma);
		m[c]++;
		getline(i, notComma, ',');
		int integer = from_string<int>(notComma);
		my_set.insert(integer);
		getline(i, notComma, ',');
		float f = from_string<float>(notComma);
	}
	
	for (auto t : m) {
		string emptyString = string(t.second, '*');
		cout << t.first << ':' << emptyString << "]" << endl;
	}
	cout << my_set.size() << " different integers " << endl;

    return 0;
}

