Hmm, but looking closely at initPuzzle(), it clearly achieves the scrambling by calling movePuzzle(...) on two occasions.
// scramble the puzzle
for (y=0; y<=ROWS*COLS; y++) {
if ((rand() % 2) == 0) {
movePuzzle(puzzle, 'v', rand() % COLS);
}
else {
movePuzzle(puzzle, 'h', rand() % ROWS);
}
}
So, this means that you have to write the code for movePuzzle(...) in order to have the puzzle scrambled. Once you have movePuzzle() coded, you can call it from the main() too (passing in the user's input).
umm... thats right... lol sorry I didn't look close enough...
I'm frustrated with the output format, but I got it now.
So the next part is complete the movePuzzle function.
The project specification says:
movePuzzle expects to be given the puzzle array, a char variable of 'v' or 'h', representing whether a vertical column or horizontal row is to be moved, and another variable indicating which column or row is to be moved.
for (y=0; y<=ROWS*COLS; y++) {
if ((rand() % 2) == 0) {
movePuzzle(puzzle, 'v', rand() % COLS);
}
else {
movePuzzle(puzzle, 'h', rand() % ROWS);
}
}
I'm still wandering about the code that suppose to go in movePuzzle
void movePuzzle(int puzzle[][COLS], char dir, int rowcol)
it takes 3 arguments right? the array puzzle, the char 'v' or 'h', and the third argument is the number of index correspond to the vertical/horizontal.
Do I use If function to swap the array around? >.<