From 98f46f8da8299c0ac08b4137cbc4ed68112307d8 Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:07:52 +0100 Subject: [PATCH] Commit 1 code --- src/main/c/sudoku.c | 47 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/main/c/sudoku.c diff --git a/src/main/c/sudoku.c b/src/main/c/sudoku.c new file mode 100644 index 0000000..8e7d480 --- /dev/null +++ b/src/main/c/sudoku.c @@ -0,0 +1,47 @@ +#include +#include +#include +#include + +#define SIZE 9 +#define EMPTY 0 +#define LEVEL_NUMBER 3 + + +int difficulty; +int selected_level; + + +void startSudoku(); //is instead of main + +void startSudoku() { + int grid[SIZE][SIZE]; + selected_level = 0; + + while (1) { + printf("\nDifficulty Function - Choose difficulty:\n"); + printf("1. Easy\n2. Medium\n3. Hard\n"); + printf("Enter the corresponding number or type 'quit' to exit: "); + + char input[10]; + scanf("%s", input); + + if (strcmp(input, "quit") == 0) { + break; + } + + difficulty = input[0] - '0'; // Convert the first character to an integer + + if ((difficulty >= 1 && difficulty <= 3) && input[1] == '\0') { + printf("Input is correct"); + } else { + printf("Invalid input. Please enter a number between 1 and 3.\n"); + } + + } +} + +int main(){ + startSudoku(); + return 0; +} \ No newline at end of file