10 typedef std::map< unsigned 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)) {
26 os << p.first << " [";
28 std::ostringstream oss;
32 oss.setf(std::ios::hex, std::ios::basefield);
34 os << oss.str() << ":" << unsigned(p.first);
35 if (isgraph(p.first)) os << "]";
36 os << " (" << double(p.second) / total * 100 << "% : "
37 << unsigned((double(p.second) / total) * 4294967296ull) << ")\n";
43 std::setlocale(LC_ALL, "es_AR");
46 std::map< char, unsigned > freq;
47 while (std::cin.get(c)) {
51 for_each(freq.begin(), freq.end(), print(std::cout, total));