#include <clocale>
#include <cstdlib>
-typedef std::map< char, unsigned > freq_type;
+typedef std::map< unsigned char, unsigned > freq_type;
class print: public std::unary_function< freq_type::value_type, void >
{
os.width(4);
os.fill(' ');
if (isgraph(p.first)) {
- os << p.first;
- } else {
- std::ostringstream oss;
- oss << "0x";
- oss.width(2);
- oss.fill('0');
- oss.setf(std::ios::hex, std::ios::basefield);
- oss << int(p.first);
- os << oss.str();
+ os << p.first << " [";
}
- os << " (" << double(p.second) / total * 100 << "%)\n";
+ std::ostringstream oss;
+ oss << "0x";
+ oss.width(2);
+ oss.fill('0');
+ oss.setf(std::ios::hex, std::ios::basefield);
+ oss << int(p.first);
+ os << oss.str() << ":" << unsigned(p.first);
+ if (isgraph(p.first)) os << "]";
+ os << " (" << double(p.second) / total * 100 << "% : "
+ << unsigned((double(p.second) / total) * 4294967296ull) << ")\n";
}
};