Input validation for arrays, so that no number is repeated?

How would I do input validation for this code, so no number is repeated?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
int table[3][3];
int row = 3;
int col = 3;

int main()
{

	for (row = 0; row < 3; row++)
	{
		for (col = 0; col < 3; col++)
		{
			table[row][col] = rand()%9;
			cout << table[row][col] << "    ";
		}
		cout << endl;
	}

    return 0;
}
You want 9 values.
You want 9 different values.
You want values [0..8].

That is like a deck of cards. It must have N unique cards. You won't construct a shuffled deck by pouring 1000 decks into a box and pulling one card at a time from the box until you have a full deck, will you?

No, you will take a full, ordered deck and shuffle it. For an idea about implementation, see http://www.cplusplus.com/reference/algorithm/shuffle/
I honestly still don't know what to do....
Did you look at the example program in the documentation of std::shuffle?
Topic archived. No new replies allowed.