Advertisement
Guest User

GRID.PAS

a guest
Feb 19th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.68 KB | None | 0 0
  1. var  i,j,n,m,c,h,t:integer;
  2.      xet:string[200];
  3.      a: array[1..200,1..200] of integer;
  4.  
  5.      function kt(var h,c:integer):integer;
  6.      var i,cot,hang,dem,dt:integer;
  7.      Begin
  8.                 dem:=0;
  9.                 dt:=0;
  10.                 for i:=1 to  n do if a[i,c] = 2 then break else dem:=dem+1;
  11.                 if dem = n then dt:=dt+1;
  12.  
  13.                 dem:=0;
  14.                 for i:=1 to m do if a[h,i] = 2 then break else dem:=dem+1;
  15.                 if dem = m then dt:=dt+1;
  16.  
  17.                 if dt = 2 then
  18.                 Begin
  19.                         a[h,c]:=2;
  20.                         t:=t+1;
  21.                 end;
  22.      end;
  23.  
  24. Begin
  25.         assign(input,'GRID.INP');
  26.         reset(input);
  27.         assign(output,'GRID.OUT');
  28.         rewrite(output);
  29.  
  30.         read(n);
  31.         readln(m);
  32.  
  33.         t:=0;
  34.         for i:=1 to m do
  35.         Begin
  36.                 readln(xet);
  37.                 for j:=1 to m do
  38.                 if xet[j] ='.' then a[i,j]:=0 else
  39.                 if xet[j] ='+' then a[i,j]:=1 else a[i,j]:=2;
  40.         end;
  41.  
  42.         t:=0;
  43.         for i:=1 to n do
  44.         Begin
  45.                 h:=i;
  46.                 for j:=1 to m do
  47.                 Begin
  48.                         c:=j;
  49.                         if a[i,j] = 1 then kt(h,c) else
  50.                         if a[i,j] = 2 then break;
  51.                 end;
  52.         end;
  53.  
  54.         writeln(t);
  55.         for i:=1 to n do
  56.         begin
  57.                 for j:=1 to m do
  58.                 case a[i,j] of
  59.                         0 : write('.');
  60.                         1 : write('+');
  61.                         2 : write('*');
  62.                 end;
  63.                 writeln;
  64.         end;
  65. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement