Browse Source

Commit 6 code

main^2
Lucas Heil 11 months ago
committed by Peter Wiebe
parent
commit
652da8fafb
  1. 29
      src/main/c/sudoku.c

29
src/main/c/sudoku.c

@ -15,6 +15,9 @@ int selected_level;
void startSudoku(); //is instead of main
void availableLevelsFunction(int difficulty);
void selectLevel(int grid[SIZE][SIZE]);
void initializeGrid(int grid[SIZE][SIZE]);
void generateSudoku(int grid[SIZE][SIZE], int difficulty, int level);
void startSudoku() {
int grid[SIZE][SIZE];
@ -64,17 +67,39 @@ void selectLevel(int grid[SIZE][SIZE]) {
level = level_select[0] - '0'; // Convert the first character to an integer
if ((level >= 1 && level <= 3) && level_select[1] == '\0') {
printf("Input is correct");
selected_level = level;
level--; // Adjust to 0-based index
generateSudoku(grid, difficulty, selected_level);
break;
} else {
printf("Invalid input. Please enter a number between 1 and 3.\n");
}
}
}
void initializeGrid(int grid[SIZE][SIZE]) {
for (int i = 0; i < SIZE; i++) {
for (int j = 0; j < SIZE; j++) {
grid[i][j] = EMPTY;
}
}
}
void generateSudoku(int grid[SIZE][SIZE], int difficulty, int level) {
initializeGrid(grid);
printf("Level is getting initialized");
}

Loading…
Cancel
Save