I have an matrix of size 3*3.
and i am interested to pick image indexes randomly.
Therefore, i did like this ...
In the below program,
1 2 3 4 5 6 7 8 9 10 11 12
m = 3, n = 3;
//random indexes must not be repeated.
//Note
//* [0][1] and [1][0] are different
//* [0][0], [1][1], [2][2], [3][3], [4][4] are symmetrical
for(int i = 0; i < 9; i++)
{
int RandIndex1 = rand() % m; //generates a random number between row (0 to 5)
int RandIndex2 = rand() % n; //generates a random number between column (0 to 5)
cout << "[" << RandIndex1 << "," << RandIndex2 << "]" << endl;
}
but the problem is...
Its possible that the generated RandIndex1 and RandIndex2 are repeated.
Now can i ignore repeated random indexes?