### Some random generator trouble

Ok, so with my sudoku generator (its acutally kenken, but same principle) I made this for my generator:
 ``1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950`` ``````#include #include //for the rand() function using namespace std; int KenKenBoard[6][6]={{0,0,0,0,0,0}, {0,0,0,0,0,0}, {0,0,0,0,0,0}, {0,0,0,0,0,0}, {0,0,0,0,0,0}, {0,0,0,0,0,0}}; int GetKenKenBoard(int x, int y) { KenKenBoard[x][y]=rand() % 6 + 1; for(int r=0; r<6 && r!=x; r++) { while(KenKenBoard[x][y]==KenKenBoard[r][y]) { KenKenBoard[x][y]=rand() % 6 + 1; } } for(int c=0; c<6 && c!=y; c++) { while(KenKenBoard[x][y]==KenKenBoard[x][c]) { KenKenBoard[x][y]= rand() % 6 + 1; } } } void PrintKenKenBoard() { for(int x=0; x<6; x++) { for(int y=0; y<6; y+++ { cout<

This code is supposed to generate a random board where numbers are not repeated in the same row and column, for example (a very bad example...):
 ```123456 315264 246315 462531 531642 654123```

But it doesn't. It compiles fine, runs, and comes out with something like this:
 ```665666 651243 552431 312563 143525 142415```

and it is always the same output. Why? Where is the problem in my code?

Please point it out, I want to make this program run so I can generate more games easily for my kenken game.
Thanks! I was really puzzled, because everything I looked at checked out, and the proogram ran, but it didnt run right. I just forgot a step.
Topic archived. No new replies allowed.