Shannon-Fano coder and decoder, C++