From a964c6ff91645918d6c9a96f79aa318ebc364466 Mon Sep 17 00:00:00 2001 From: p7cx2jokr <2160925370@qq.com> Date: Fri, 22 Nov 2024 20:10:10 +0800 Subject: [PATCH] Delete '8.c' --- 8.c | 51 --------------------------------------------------- 1 file changed, 51 deletions(-) delete mode 100644 8.c diff --git a/8.c b/8.c deleted file mode 100644 index 4bd9a1a..0000000 --- a/8.c +++ /dev/null @@ -1,51 +0,0 @@ -#include -#include -#include -#define SIZE 9 -void printSudoku(int matrix[SIZE][SIZE]) { - for (int i = 0; i < SIZE; i++) { - if (i % 3 == 0) { - printf("-------------------------\n"); - } - for (int j = 0; j < SIZE; j++) { - if (j % 3 == 0) { - printf("| "); - } - printf("%d ", matrix[i][j]); - } - printf("|\n"); - } - printf("-------------------------\n"); -} -void shuffleArray(int arr[], int size) { - for (int i = size - 1; i > 0; i--) { - int j = rand() % (i + 1); - int temp = arr[i]; - arr[i] = arr[j]; - arr[j] = temp; - } -} -void generateIncompleteMatrix(int matrix[SIZE][SIZE]) { - srand(time(0)); - int nums[SIZE] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; - for (int blockRow = 0; blockRow < SIZE; blockRow += 3) { - shuffleArray(nums, SIZE); - int idx = 0; - for (int i = 0; i < 3; i++) { - int count = 3; - while (count > 0) { - int j = rand() % SIZE; - if (matrix[blockRow + i][j] == 0) { - matrix[blockRow + i][j] = nums[idx++]; - count--; - } - } - } - } -} -int main() { - int matrix[SIZE][SIZE] = { 0 }; - generateIncompleteMatrix(matrix); - printSudoku(matrix); - return 0; -}