You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
926 B
50 lines
926 B
1 year ago
|
#include <stdio.h>
|
||
|
#include <stdlib.h>
|
||
|
#include <time.h>
|
||
|
|
||
|
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;
|
||
|
}
|