0

Hi
I only have a simple query I am relatively new to c++ and I am trying to create 10 randomly placed items in a grid. I've used the following for loop:

for(int x=0; x<10; x++)
    {              
            array[n1][n2] = aliveG;  
    }

and it only displays the item once, n1 and n2 are 2 random numbers.

Thanks in advance!

Edited by katieJane: n/a

2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by Jiwe
0

So if you say that n1 and n2 are 2 random values, there is no line of code inside the for loop to tell them to change their values so they always remain the same, you can't expect they will change randomly out of nowhere.

Hint: If you want to assign random values for the grid positions, put some code in the for loop so the values of n1 and n2 change each time the for loops.

Edited by Jiwe: n/a

0

Thank you very much for the help that has just sorted my problem! :)

Edited by katieJane: n/a

0

Anytime! Glad I could help :).

Edit: If your question is fully answered please mark the thread as solved thanks! :).

Edited by Jiwe: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.