Some random generator trouble

Ok, so with my sudoku generator (its acutally kenken, but same principle) I made this for my generator:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <iostream>
#include <cstdlib>//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<<KenKenBoard[x][y]
  }
  cout<<endl;
 }
}
int main()
{
  for(int x=0; x<6; x++)
 {
  for(int y=0; y<6; y++)
  {
   GetKenKenBoard(x,y);
  }
 }
 PrintKenKenBoard();
 cin.get();
}

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.