Markov chain generator in C++