parent
a799a5f83c
commit
8dde4cf73f
@ -1,44 +0,0 @@
|
|||||||
#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;
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in new issue