From 89a79037c483c3151741e6906844630256d93b4d Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:20:33 +0100 Subject: [PATCH] Commit 27 code --- src/main/c/sudoku.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/main/c/sudoku.c b/src/main/c/sudoku.c index 74e1c47..fd4b62d 100644 --- a/src/main/c/sudoku.c +++ b/src/main/c/sudoku.c @@ -508,11 +508,31 @@ void inputFunction(int grid[SIZE][SIZE]) { break; case 2: - printf("Case 2 \n"); + printf("Enter the coordinates (row and column) separated by space:\n"); + int row_d, col_d; + + + while (true){ + char rowd_str[10]; + char cold_str[10]; + scanf("%s %s", rowd_str, cold_str); + + row_d = rowd_str[0] - '0'; // Convert the first character to an integer + col_d = cold_str[0] - '0'; // Convert the first character to an integer + + if (((row_d >= 1 && row_d <= 9) && rowd_str[1] == '\0') && ((col_d >= 1 && col_d <= 9) && cold_str[1] == '\0')) { + grid[row_d - 1][col_d - 1] = 0; + printf("Cell cleared successfully.\n"); + break; + } else { + printf("Invalid input. Please enter a number between 1 and 9.\n"); + } + } break; default: printf("Invalid input. Please enter 1 or 2.\n"); } + }