From 7d583c0f215422d3d82dbf2c6729b0e9168c5445 Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:16:37 +0100 Subject: [PATCH] Commit 20 code --- src/main/c/sudoku.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/c/sudoku.c b/src/main/c/sudoku.c index 353c70b..23ee743 100644 --- a/src/main/c/sudoku.c +++ b/src/main/c/sudoku.c @@ -404,7 +404,24 @@ void tipFunction(int grid[SIZE][SIZE]) { break; case 2: - printf("Case 2\n"); + printf("Enter the coordinates (top-left cell of the 3x3 field) separated by space:\n"); + int startRow, startCol; + + while (true){ + char row_squ[10]; + char col_squ[10]; + scanf("%s %s", row_squ, col_squ); + + + startRow = row_squ[0] - '0'; // Convert the first character to an integer + startCol = col_squ[0] - '0'; // Convert the first character to an integer + + if (((startRow >= 1 && startRow <= 9) && row_squ[1] == '\0') && ((startCol >= 1 && startCol <= 9) && col_squ[1] == '\0')) { + break; + } else { + printf("Invalid input. Please enter a number between 1 and 9.\n"); + } + } break; case 3: