1. ## sudoku - arrays

Hi guys, im currently in the process of making a sudoku solver. At present it can solve the easier puzzles, but not the hard ones. I saw on another site the following code

Code:
# const uint lineElements[L][C] = {
#     { 0,  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, 51, 52, 53},
#     {54, 55, 56, 57, 58, 59, 60, 61, 62},
#     {63, 64, 65, 66, 67, 68, 68, 70, 71},
#     {72, 73, 74, 75, 76, 77, 78, 79, 80}
# };
#
# const uint columnElements[C][L] = {
#     { 0,  9, 18, 27, 36, 45, 54, 63, 72},
#     { 1, 10, 19, 28, 37, 46, 55, 64, 73},
#     { 2, 11, 20, 29, 38, 47, 56, 65, 74},
#     { 3, 12, 21, 30, 39, 48, 57, 66, 75},
#     { 4, 13, 22, 31, 40, 49, 58, 67, 76},
#     { 5, 14, 23, 32, 41, 50, 59, 68, 77},
#     { 6, 15, 24, 33, 42, 51, 60, 69, 78},
#     { 7, 16, 25, 34, 43, 52, 61, 70, 79},
#     { 8, 17, 26, 35, 44, 53, 62, 71, 80}
# };
#
What does this do? does it assign a number to every array entry?

At the moment i have many for loops to get values from the array. Is this a way of simply referencing, say array[3][6] as the number 47. This would make it a lot easier as with 1 loop, I could check both the vertical and horizontal numbers.

Am i right? if so, how would i declare this in c++

Thanks

2. Originally Posted by rocketman50

Am i right? if so, how would i declare this in c++

Thanks
You would remove all those # signs from the left column.

And yes, this assigns numbers to the array -- remember that the last number changes fastest, so that first row of numbers would be array[0][whatever].

3. Originally Posted by tabstop
You would remove all those # signs from the left column.

And yes, this assigns numbers to the array -- remember that the last number changes fastest, so that first row of numbers would be array[0][whatever].
Thanks