Hello, I've searched around and found similar threads to my question, but haven't really found something that has helped this concept click. I'm trying to create 4x4 array that holds 8 pairs of numbers in randomly generated spaces. For example, the array:
1 1 2 2
3 3 4 4
5 5 6 6
7 7 8 8
Would look something like this:
3 1 2 4
8 7 7 5
1 4 3 6
6 2 5 8
Or something similar, with each number having only one copy of it exist. The function I've written to do this is as follows
int funArray[4][4]
void createArray(int funArray[][4])
{
srand((unsigned)time(NULL);
for(int a = 0;a<4;a++)
{
for(int b = 0;b<4;b++)
{
funArray[a][b]=rand()%8+1;
}
}
}
I understand that I'm just entering a random number from 1-8 into the two-dimensional array, but I'm having a hard time understanding how to populate it with pairs of numbers. Any help or resources would be appreciated. I'm not looking for someone to just do it for me, but hoping to understand what I need to do. Thanks.