Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.81 KB | None | 0 0
  1. var i,j,poc: byte;
  2.     mapa: array[1..40,1..40] of char;
  3.     vys: array[1..40,1..40] of byte;
  4.    
  5. const a = 6; b = 33;
  6.  
  7. procedure lesik(x,y:byte);
  8.         Begin
  9.             if mapa[x,y] = '^' then
  10.             Begin
  11.             vys[x,y] := poc;
  12.             mapa[x,y] := '.';
  13.             if x>=2 then lesik(x-1,y);
  14.             if y>=2 then lesik(x,y-1);
  15.             if x<=a-1 then lesik(x+1,y);
  16.             if y<=b-1 then lesik(x,y+1);
  17.             end;
  18.         end;
  19.            
  20.  
  21. Begin
  22. assign(input,'mapa.in'); reset(input);
  23. poc := 1;
  24. for i:=1 to a do
  25.     Begin
  26.     for j:=1 to b do
  27.         read(mapa[i,j]);
  28.     readln;
  29.     end;
  30.    
  31. for i:=1 to a do
  32.     Begin
  33.     for j:=1 to b do
  34.         write(mapa[i,j]);
  35.     writeln;
  36.     end;
  37.  
  38. for i:=1 to a do
  39.     for j:=1 to b do
  40.         if mapa[i,j] = '^' then
  41.             Begin
  42.             lesik(i,j);
  43.             poc := poc+1;
  44.             end;
  45.        
  46.    
  47. for i:=1 to a do
  48.     Begin
  49.     for j:=1 to b do
  50.         write(vys[i,j]);
  51.     writeln;
  52.     end;       
  53.  
  54. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement