program sudoku; uses wincrt; type short=1..9; var i,k,j,n,l,p,q,limk1,limk2,limi1,limi2:short; ch,num:string[1]; x,y:integer; b,t:boolean; key:char; M:array [1..9,1..9] of string[1]; xy:array [1..2,1..81] of integer; label theend,randoms; begin {gotoxy(11,11);} write('*Welcome to Sudoku Game!*'); {gotoxy(11,12);} write('(Press Enter to start...)'); {gotoxy(9,24);} write('All rights reserved to CrYmFoX 2016.'); {gotoxy(11,13);} readln; {clrscr;} writeln(' _____________________________________________________ '); writeln('| | | | | | | | | |'); writeln('|_____|_____|_____|_____|_____|_____|_____|_____|_____|'); writeln('| | | | | | | | | |'); writeln('|_____|_____|_____|_____|_____|_____|_____|_____|_____|'); writeln('| | | | | | | | | |'); writeln('|_____|_____|_____|_____|_____|_____|_____|_____|_____|'); writeln('| | | | | | | | | |'); writeln('|_____|_____|_____|_____|_____|_____|_____|_____|_____|'); writeln('| | | | | | | | | |'); writeln('|_____|_____|_____|_____|_____|_____|_____|_____|_____|'); writeln('| | | | | | | | | |'); writeln('|_____|_____|_____|_____|_____|_____|_____|_____|_____|'); writeln('| | | | | | | | | |'); writeln('|_____|_____|_____|_____|_____|_____|_____|_____|_____|'); writeln('| | | | | | | | | |'); writeln('|_____|_____|_____|_____|_____|_____|_____|_____|_____|'); writeln('| | | | | | | | | |'); writeln('|_____|_____|_____|_____|_____|_____|_____|_____|_____|'); randomize; for k:=1 to 9 do begin if k in [1..3] then begin limk1:=1; limk2:=3; end else if k in [4..6] then begin limk1:=4; limk2:=6; end else begin limk1:=7; limk2:=9 end; for i:=1 to 9 do begin if i in [1..3] then begin limi1:=1; limi2:=3; end else if i in [4..6] then begin limi1:=4; limi2:=6; end else begin limi1:=7; limi2:=9 end; str(random(9)+1,ch); b:=true; for j:=1 to 9 do b:=b and (ch <> M[j,k]); for l:=1 to 9 do b:=b and (ch <> M[i,l]); for p:=limk1 to limk2 do for q:=limi1 to limi2 do b:=b and (ch <> M[q,p]); if b=true then M[i,k]:=ch; end; end; x:=4; for k:=1 to 9 do begin y:=2; for i:=1 to 9 do begin {gotoxy(x,y);} write(M[i,k]); if M[i,k] <> '' then begin xy[1,k]:=x; xy[2,k]:=y end; y:=y+2 end; x:=x+6 end; x:=4; y:=2; {gotoxy(x,y);} repeat key:=readkey; case key of 'z' : y:=y-2; 's' : y:=y+2; 'd' : x:=x+6; 'q' : x:=x-6; 'p' : goto TheEnd; '1' .. '9' : num:=key; end; case y of 0 : y:=2; 20 : y:=18; end; case x of -2 : x:=4; 58 : x:=52; end; {gotoxy(x,y);} write(num); {gotoxy(x,y);} num:=''; until keypressed; TheEnd: {clrscr;} {gotoxy(16,16);} write('The game is over, press Alt+F4 to exit...') end.