|
@ -448,8 +448,35 @@ void tipFunction(int grid[SIZE][SIZE]) { |
|
|
|
|
|
|
|
|
void inputFunction(int grid[SIZE][SIZE]) { |
|
|
void inputFunction(int grid[SIZE][SIZE]) { |
|
|
printf("\nInput function - Choose an action:\n"); |
|
|
printf("\nInput function - Choose an action:\n"); |
|
|
|
|
|
printf("1. Insert value in an empty field\n"); |
|
|
|
|
|
printf("2. Clear an already filled field\n"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int action; |
|
|
|
|
|
|
|
|
|
|
|
while (true){ |
|
|
|
|
|
char in_str[10]; |
|
|
|
|
|
scanf("%s", in_str); |
|
|
|
|
|
|
|
|
|
|
|
action = in_str[0] - '0'; // Convert the first character to an integer |
|
|
|
|
|
|
|
|
|
|
|
if ((action >= 1 && action <= 2) && in_str[1] == '\0') { |
|
|
|
|
|
break; |
|
|
|
|
|
} else { |
|
|
|
|
|
printf("Invalid input. Please enter a number between 1 and 2.\n"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
switch (action) { |
|
|
|
|
|
case 1: |
|
|
|
|
|
printf("Case 1 \n"); |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case 2: |
|
|
|
|
|
printf("Case 2 \n"); |
|
|
|
|
|
break; |
|
|
|
|
|
default: |
|
|
|
|
|
printf("Invalid input. Please enter 1 or 2.\n"); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|