Yep, I'm a newbie and totally out of my depth! Playing around with the idea of a dungeon crawl but when I populate my traps into the 2d array, rand duplicates and overwrites its previous locations (for example 99 traps randomly generated into a 10 x 10 does not fill 99 locations with 1 (previously all set to 0) leaving just one 0 remaining, you get my drift)!

Tried numerous ways (within my limited knowledge) but cannot work out how to check if previous local has already been populated with a 1, basically gettting rand to check each go before continueing? Hope this makes sense.

(I don't really understand my rand % 10 bit (borrowed it from another crawl, so don't know how to split it)?

Any help, apart from give up for now, would be most helpful?

Thanks in advance.

Here's my code.

```
#include <iostream>
using namespace std;
int main()
{
const int nNumRows = 10; //down
const int nNumCols = 10; //across
int array[nNumRows][nNumCols] = { 0 }; // will eventually display
int array_check[nNumRows][nNumCols] = { 0 };
int randx = 0, randy =0; //random values
int x = 0, y = 0; //x-axis and y-axis position
int n, counter = 0;
int p = 0;
srand((unsigned)time(0)); //set off random counter
// Doesn't work! Rand places 99 x 1 but must overwrite itself on placements?
for ( p=1 ; p<100 ; p++ )
{
randx =rand()% 10;
randy =rand()% 10;
array_check[randx][randy]=1;
if (p == 99)
break;
// counter += array_check[nNumRows][nNumCols];
// array_check[randx][randy]=1;
}
cout << p << endl;
//do {
// randx =rand()% 10;
// randy =rand()% 10;
// if (array_check[randx][randy]!=2)
// array_check[randx][randy]=1;
// counter++; // adds one to counter
// }while (counter != 99); // compares till they equal
//for (n=0; n<=98; n++)
// {
// randx =rand()% 10;
// randy =rand()% 10;
// array_check[randx][randy]=1;
// }
//for (randx = 0; randx <10; randx++)
// for (randy=0; randy<10; randy++)
// if (array_check[randx][randy] !=1)
// array_check[randx][randy]=2;
// else (array_check [randx][randy] =0);
// array_check[randx][randy]=4;
for (int nRow = 0; nRow < nNumRows; nRow++)
{
for (int nCol = 0; nCol < nNumCols; nCol++)
cout << array_check[nRow][nCol] << " ";
cout << endl;
}
system("PAUSE");
return 0;
}
```

I know the codes ultra messy but I thought it was important to show you my attempts at sorting it.

Thanks, Leppie