You probably forgot to use srand to seed the PRNG.

Also, if the numbers must be different on each iteration, then you would be better off creating an array of integers from 1 to 5 then shuffling the array with std::random_shuffle.