Среда разработки: Turbo Pascal 7.1
uses crt; var mas8:array[1..9] of integer; i,x,pozx,pozzero:byte; mas:set of byte; win:boolean; ch:char; begin randomize; mas:=[]; for i:=1 to 9 do begin repeat x:=random(9); until not(x in mas); mas8[i]:=x; mas:=mas+[x]; end; repeat clrscr; writeln(' Восьмерки.'); writeln; writeln(' Целью игры является выстроение по возрастанию цифр от 1 до 8 в квадрате 3x3.'); writeln(' Разрешается менять пустую фишку на соседнюю с ней по вертикали или горизонтали.'); writeln(' Для перемещения фишки нажмите цифру с ее номером.'); writeln(' Для выхода из программы нажмите клавишу ESC.'); writeln; textcolor(yellow); for i:=1 to 9 do begin if i in [1,4,7] then writeln(#32#201#205#205#205#187#32#201#205#205#205#187#32 #201#205#205#205#187); if mas8[i]=0 then write (#32#186#32#32#32#186) else write(#32#186#32,mas8[i],#32#186); if i in [3,6,9] then begin writeln; writeln(#32#200#205#205#205#188#32#200#205#205#205#188#32 #200#205#205#205#188);end; end; textcolor(7); writeln; writeln(' (с) Бутко А.В.'); repeat ch:=readkey; x:=ord(ch)-48; if ch=#27 then exit; until x in mas; for i:=1 to 9 do begin if mas8[i]=x then pozx:=i; if mas8[i]=0 then pozzero:=i; end; if (pozx=pozzero-3) or (pozx=pozzero+3) or (pozx in [3,6,9,2,5,8]) and (pozx=pozzero+1) or (pozx in [1,4,7,2,5,8]) and (pozx=pozzero-1) then begin mas8[pozx]:=0; mas8[pozzero]:=x; win:=true; for i:=1 to 8 do if mas8[i]<>i then win:=false; end; until win; clrscr; write('Поздравляем. Вы выиграли'); readkey; end.