Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program Project1;
- {$APPTYPE CONSOLE}
- uses
- SysUtils;
- var
- N, M, i, j, sveti, svetj: integer;
- Lab: array[1..1000,1..1000] of Char;
- procedure svet_go(i, j, di, dj: integer);
- var
- curi, curj: integer;
- begin
- if not ((Lab[i+di, j]='*') and (Lab[i, j+dj]='*')) then
- begin
- if (i+di>0) and (i+di<N+1) then curi:=i+di else begin curi:=i; di:=-di; end;
- if (j+dj>0) and (j+dj<M+1) then curj:=j+dj else begin curj:=j; dj:=-dj; end;
- if (Lab[curi, curj]<>'*') and (Lab[curi, curj]<>'X') then
- begin
- if (di*dj>0) and (Lab[curi, curj]='.') then Lab[curi, curj]:='\';
- if (di*dj>0) and (Lab[curi, curj]='/') then Lab[curi, curj]:='X';
- if (di*dj<0) and (Lab[curi, curj]='.') then Lab[curi, curj]:='/';
- if (di*dj<0) and (Lab[curi, curj]='\') then Lab[curi, curj]:='X';
- svet_go(curi, curj, di, dj);
- end;
- if Lab[curi, curj]='*' then begin
- if (Lab[curi-di, curj]='*') and (Lab[curi, curj-dj]<>'*') then
- begin
- curj:=curj-dj;
- dj:=-dj;
- if (di*dj>0) and (Lab[curi, curj]='.') then Lab[curi, curj]:='\';
- if (di*dj>0) and (Lab[curi, curj]='/') then Lab[curi, curj]:='X';
- if (di*dj<0) and (Lab[curi, curj]='.') then Lab[curi, curj]:='/';
- if (di*dj<0) and (Lab[curi, curj]='\') then Lab[curi, curj]:='X';
- svet_go(curi, curj, di, dj);
- end;
- if (Lab[curi-di, curj]<>'*') and (Lab[curi, curj-dj]='*') then
- begin
- curi:=curi-di;
- di:=-di;
- if (di*dj>0) and (Lab[curi, curj]='.') then Lab[curi, curj]:='\';
- if (di*dj>0) and (Lab[curi, curj]='/') then Lab[curi, curj]:='X';
- if (di*dj<0) and (Lab[curi, curj]='.') then Lab[curi, curj]:='/';
- if (di*dj<0) and (Lab[curi, curj]='\') then Lab[curi, curj]:='X';
- svet_go(curi, curj, di, dj);
- end;
- end;
- end;
- end;
- begin
- readln(N, M);
- for i:=1 to N do for j:=1 to M do begin
- if j<>M then read(Lab[i,j]) else readln(Lab[i,j]);
- if Lab[i,j]='X' then begin
- sveti:=i;
- svetj:=j;
- end;
- end;
- svet_go(sveti, svetj, 1, 1);
- svet_go(sveti, svetj, 1, -1);
- svet_go(sveti, svetj, -1, 1);
- svet_go(sveti, svetj, -1, -1);
- writeln;
- for i:=1 to N do for j:=1 to M do if j<>M then write(Lab[i,j]) else writeln(Lab[i,j]);
- readln;
- end.
Add Comment
Please, Sign In to add comment