You can insert a no. at any pt. in this program. here is the code:
#include<stdio.h>
#include<conio.h>
#include<process.h>
#include"goto.c"
void line(void);
void cross(void);
int main()
{
clrscr();
int a[9][9]={8,6,7,5,4,2,3,9,1,
4,3,2,9,1,8,5,7,6,
9,5,1,7,6,3,4,2,8,
5,2,9,6,8,4,7,1,3,
7,4,8,3,5,1,2,6,9,
6,1,3,2,7,9,8,5,4,
1,8,5,4,2,6,9,3,7,
2,9,6,8,3,7,1,4,5,
3,7,4,1,9,5,6,8,2},
b[9][9]= {8,6,' ',' ',' ',' ',' ',9,' ',
4,' ',2,' ',1,' ',5,' ',' ',
' ',5,' ',7,' ',3,' ',' ',8,
5,' ',' ',6,8,4,' ',1,' ',
' ',4,' ',' ',' ',' ',2,6,' ',
' ',' ',3,2,7,9,8,' ',4,
' ',' ',' ',' ',' ',6,' ',' ',7,
2,' ',6,8,3,7,1,' ',' ',
' ',7,4,' ',' ',' ',' ',8,2},i,j,r=0,c=0,ch,n;
textcolor(55);
{cprintf("\n READ THE INSTRUCTIONS CAREFULLY");
printf("\n\n\n");
textcolor(GREEN);
cprintf("1.) FILL NO.S FROM 1 TO 9 IN EVERY ROW , COLUMN & 3*3 BOX");
printf("\n");
cprintf(" 2.) NO Number SHOULD REPEAT MORE THAN ONCE");}
delay(10000);
textcolor(55);
clrscr();
for(i=0;i<9;i++)
{
printf("\n");
for(j=0;j<9;j++)
{printf("%3d",b[i][j]);
if (b[i][j]==32)
printf("\b\b _");}
printf("\n");
}
gotorc(0,0);
printf("%c",218);
for(i=0;i<17;i++)
printf("\n%c",179);
printf("\n%c",192);
line();
gotorc(0,1);line();
gotorc(6,1);line();
gotorc(12,1);line();
gotorc(0,9);cross();
gotorc(0,18);cross();
gotorc(0,27);cross();
gotorc(6,31);
printf("1.use errow key to move");
gotorc(7,31);
printf("2.press insert to insert a no. & then press enter");
gotorc(8,31);
printf("3.insert a no. at blank given");
gotorc(0,0);
while(1)
{
ch=getkey();
switch(ch)
{
case 77:
gotorc(r,++c);
break;
case 80:
{
gotorc(++r,c); break;
}
case 75:
{
gotorc(r,--c); break;
}
case 1:
exit(0);
case 72:
gotorc(--r,c);break;
case 82:
scanf("%d",&n);
gotorc(r,c);
printf("%d",n);
}
}
getch();
return(0);
}
void line(void)
{
int i;
for(i=0;i<27;i++)
cprintf("%c",196);
}
void cross(void)
{
int i;
for(i=0;i<=18;i++)
{
if(i==0)
cprintf("%c\n",194);
else if(i==6||i==12)
cprintf("\b%c\n",197);
else if(i==18)
cprintf("\b%c\n",193);
else
cprintf("\b%c\n",179);
}
}
run this code in your TC.
you need to copy the foll. in TC
[ATTACH]12301[/ATTACH]
please see attachment goto.c
please let me know how can i check that my filled sudoku is right or wrong. (note that it is not necessary to fill first blank first , i can fill it randomly)