Вот быренько подправил твой код(вспомнил паскаль=)). Советую писать на паскале соблюдая регистр - так читать удобнее. Теперь координаты считаются от левого верхнего угла вниз - Y, вправо - X. Не злоупотребляй бессмысленной рекурсией
| Код | program fiver; uses crt; const ct = 5; var mas : array[1..ct,1..ct] of integer; i,j,a : integer; x,y : integer;
begin for i:= 1 to ct do for j:= 1 to ct do mas[i,j] := -1; while true do begin a := 0; ClrScr; for i:= 1 to ct do begin for j:= 1 to ct do begin if mas[i, j] = -1 then Write(' o') else begin a := a + 1; Write(' x'); end; end; WriteLn; end; if a = ct * ct then begin WriteLn('You win!!!'); ReadKey; Halt; end; Write('X= '); ReadLn(x); Write('Y= '); ReadLn(Y); if (x > ct) or (x < 0) or (y > ct) or (y < 0) then continue; mas[y, x] := mas[y, x] * -1; if x + 1 <= ct then mas[y, x + 1] := mas[y, x + 1] * -1; if x - 1 > 0 then mas[y, x - 1] := mas[y, x - 1] * -1; if y + 1 <= ct then mas[y + 1, x] := mas[y + 1, x] * -1; if y - 1 > 0 then mas[y - 1, x] := mas[y - 1, x] * -1; end; end.
|
|