C++ version for Monte_Carlo program in lecture