Original Post
I have a question, I have 3 different rand()%10's inside 2 for loops, and the output is random numbers but they are the 3 same in a row, and my output is like 111 666 333 888 666 222 666 222 times 100, for every cell on the board. How can I get it to change every time so its like 356 864 373 266 like that? Thanks.
#include <iostream>
#include <cstdlib>
#include <time.h>
using namespace std;
union Block {
int color, relxloc, relyloc;
};
Block board[10][10];
int main() {
srand((unsigned)time( NULL ));
for(int y=0;y<10;y++) {
for(int x=0;x<10;x++) {
board[x][y].color = rand()%10;;
board[x][y].relxloc = rand()%10;;
board[x][y].relyloc = rand()%10;;
cout<<board[x][y].color<<" "<<board[x][y].relxloc<<" "<<board[x][y].relyloc<<endl;
}
}
return 0;
}