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; +}