Random C++ exercise