From 4900da6ac0c39fde3dbff12fed1e994851d19a27 Mon Sep 17 00:00:00 2001 From: pfjlev589 <1600351482@qq.com> Date: Sun, 5 Nov 2023 21:50:03 +0800 Subject: [PATCH] ADD file via upload --- 2.txt | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 2.txt diff --git a/2.txt b/2.txt new file mode 100644 index 0000000..41f1361 --- /dev/null +++ b/2.txt @@ -0,0 +1,49 @@ +#include +#include +#include + +int main() +{ + int a[9][9] = { 0 }; + int i, j, k; + srand(time(NULL)); + + printf("|-------------------|\n"); + + for (i = 0; i < 9; i++) + { + for (j = 0; j < 9; j++) + { + if (j % 3 == 0) + printf("|"); + + if (rand() % 3 == 0) + { + do + { + k = rand() % 9 + 1; + } while (a[i][k - 1] != 0); + + a[i][k - 1] = k; + printf("%d", k); + } + else + { + a[i][j] = 0; + printf("."); + } + + if (j == 8) + printf("|"); + + printf(" "); + } + + printf("\n"); + + if ((i + 1) % 3 == 0) + printf("|-------------------|\n"); + } + + return 0; +}