Nombre Password [ Regístrate ]

De picos pardos (OIE 5 - 2001) - Código en Pascal
{ OIE 2001 }
{ De picos pardos }
{ Revision: 5/9/2001 }

Program picos_pardos;
var
  FileIn, FileOut : Text;
  ant, pic, n, pos : Integer;
begin
  assign(FileIn, 'PIC.DAT');
  Reset(FileIn);
  Assign(FileOut, 'PIC.RES');
  Rewrite(FileOut);

  while Not Eof(FileIn) do begin
    Read(FileIn, n);
    ant := 0; pic := 0; pos := 1;
    while n <> 0 do begin
      if ant = 0 then begin
        ant := n;
        continue;
      end;
      if n > ant then pic := 1
      else if n = ant then begin if pic <> 0 then inc(pic) end
      else if pic <> 0 then begin
        if pos-pic <> 1 then writeln(FileOut,pos - pic, ' ', pic);
        pic := 0
      end;
      ant := n;
      Read(FileIn, n); inc(pos)
    end;
    if ant <> 0 then writeln(FileOut,'***')
  end;
  close(filein); close(fileout);
end.


© (2001-2008) ALGORITMIA.NET - Política de privacidad