# How to Generate Array of Random Integers

I am a newbie in using OpenCV. I am trying to generate a column vector (say of size 10x1) initialized to zeros and fill five randomly selected elements of this vector with some non-zero values. To choose the five random indices, I have to generate an array of 5 integers, in which, each element ranging between 0-9. Then I can fill some non-zero value at each of these randomly generated positions. Is there some way to generate an array of random integers in which the range of integers can be restricted.? Of course I can go ahead with the brute force approach by picking the elements one by one, but when I use in the real situation, the matrix dimensions will be larger and I think it will be tedious job to do it using a loop. I was checking to see some direct methods like randn() or randu().