-
-
Save anonymous/86bdd4c778dc8001ea475b63cb91a79b to your computer and use it in GitHub Desktop.
fifteen.c - shared from CS50 IDE
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int init(void) | |
{ | |
// TODO | |
int i; | |
int j; | |
int board[DIM_MAX][DIM_MAX]; | |
int x = d*d; | |
for ( i = 0; i < d; i ++) | |
{ | |
for ( j = 0; j < d; j++) | |
{ | |
x = x-1; | |
board[i][j] = x; | |
} | |
} | |
// Swap 2 and 1 | |
if ((((d * d) - 1) % 2) != 0) | |
{ | |
int hold = board[d-1][d-2]; | |
board[d-1][d-2] = board[d-1][d-3]; | |
board[d-1][d-3] = hold; | |
} | |
return board[i][j]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment