Cod sursa(job #273456)

Utilizator chimistuFMI Stirb Andrei chimistu Data 8 martie 2009 16:55:59
Problema Teren Scor 10
Compilator fpc Status done
Runda Arhiva de probleme Marime 1.28 kb
var n,m,i,j,max,c1,c0:integer;
    a:array[1..100,1..100] of integer;
    f,g:text;
begin
     assign(f,'teren.in');
     reset (f);
     read (f,n);read (f,m);
     for i:=1 to n do
     begin
          for j:=1 to m do
          read (f,a[i,j]);
     end;
     close (f);
     writeln('Terenul ');
     for i:=1 to n do
     begin
          for j:=1 to m do
          write (a[i,j],' ');
          writeln;
     end;max:=0;c1:=0;c0:=0;
     for i:=1 to n do
     begin
          for j:=1 to m do
          begin
          if a[i,j]=0 then
             c0:=c0+1;
          if a[i,j]=1 then
             c1:=c1+1;
          end;
          if c1>1 then
          begin
               c1:=0;
               c0:=0;
          end;
          if c0>max then
             max:=c0+c1;
     end;
     for i:=1 to m do
     begin
          for j:=1 to n do
          begin
          if a[i,j]=0 then
             c0:=c0+1;
          if a[i,j]=1 then
             c1:=c1+1;
          end;
          if c1>1 then
          begin
               c1:=0;
               c0:=0;
          end;
          if c0>max then
             max:=c0+c1;
     end;
     write ('max e ',max);
     assign (g,'teren.out');
     rewrite (g);
     write (g,max);
     close (g);
end.