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.
45 lines
667 B
45 lines
667 B
#include<stdio.h>
|
|
#include<stdlib.h>
|
|
#include<time.h>
|
|
int a[10][10]={0};
|
|
void random()
|
|
{
|
|
int i=1,j=1,x,y;
|
|
while(j<=3){
|
|
i=1;
|
|
while(i<=9)
|
|
{
|
|
x=rand()%3;
|
|
y=rand()%9;
|
|
if(a[x+1+(j-1)*3][y+1]==0)
|
|
{
|
|
a[x+1+(j-1)*3][y+1]=i;i++;
|
|
}
|
|
}
|
|
j++;
|
|
}
|
|
}
|
|
void format(int s[][10])
|
|
{
|
|
printf("-------------------------\n");
|
|
for(int i=1;i<10;i++)
|
|
{
|
|
printf("| ");
|
|
for(int j=1;j<10;j++)
|
|
{
|
|
|
|
printf("%d ",s[i][j]);
|
|
if(j%3==0) printf("| ");
|
|
}
|
|
printf("\n");
|
|
if(i%3==0) printf("-------------------------\n");
|
|
}
|
|
}
|
|
int main()
|
|
{
|
|
random();
|
|
format(a);
|
|
return 0;
|
|
}
|
|
|