10 typedef std::map< char, unsigned > freq_type;
12 class print: public std::unary_function< freq_type::value_type, void >
17 print(std::ostream& out, unsigned total) : os(out), total(total) {}
18 void operator() (const freq_type::value_type& p)
22 os << p.second << ": ";
25 if (isgraph(p.first)) {
28 std::ostringstream oss;
32 oss.setf(std::ios::hex, std::ios::basefield);
36 os << " (" << double(p.second) / total * 100 << "%)\n";
42 std::setlocale(LC_ALL, "es_AR");
45 std::map< char, unsigned > freq;
46 while (std::cin.get(c)) {
50 for_each(freq.begin(), freq.end(), print(std::cout, total));