parent
24163cbb5f
commit
978cdb004e
@ -0,0 +1,47 @@
|
||||
#include<stdio.h>
|
||||
#define SIZE 9
|
||||
void printSudoku(int board[SIZE][SIZE]);
|
||||
int main()
|
||||
{
|
||||
int board[SIZE][SIZE]={{5,3,0,0,7,0,0,0,0},
|
||||
{6,0,0,1,9,5,0,0,0},
|
||||
{0,9,8,0,0,0,0,6,0},
|
||||
{8,0,0,0,6,0,0,0,3},
|
||||
{4,0,0,8,0,3,0,0,1},
|
||||
{7,0,0,0,2,0,0,0,6},
|
||||
{0,6,0,0,0,0,2,8,0},
|
||||
{0,0,0,4,1,9,0,0,5},
|
||||
{0,0,0,0,8,0,0,7,9}};
|
||||
printSudoku(board);
|
||||
return 0;
|
||||
}
|
||||
void printSudoku(int board[SIZE][SIZE])
|
||||
{
|
||||
for (int i=0;i<SIZE;i++)
|
||||
{
|
||||
for(int j=0;j<SIZE;j++)
|
||||
{
|
||||
printf("%2d",board[i][j]);
|
||||
if((j+1)%3==0&&j<SIZE-1)
|
||||
{
|
||||
printf("|");
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
if((i+1)%3==0&&i<SIZE-1)
|
||||
{
|
||||
for(int k=0;k<SIZE;k++)
|
||||
{
|
||||
if((k+1)%3==0&&k<SIZE-1)
|
||||
{
|
||||
printf("|");
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("---");
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue