Cod sursa(job #46786)

Utilizator ioraIoana Radu iora Data 2 aprilie 2007 22:42:22
Problema Text Scor 90
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.97 kb
var k,s:char;
    nrc,nr,ok,l:longint;
    f2,f1:text;
function verf(s:char):integer;
var ok:longint;
i:char;
begin

  ok:=0;
  for i:='a' to 'z' do
    if s=i then begin ok:=1; break end;
  for i:='A' to 'Z' do
    if s=i then begin ok:=1; break end;
  verf:=ok;
end;
begin

  assign(f1,'text.in');
  reset(f1);
  assign(f2,'text.out');
  rewrite(f2);
  nr:=0;
  nrc:=0;
  read(f1,s);
  k:=s;
  while (not eof(f1)) do
    begin
      ok:=verf(s);
      if  ok=1 then  begin l:=1;nr:=nr+1   end
        else
          begin
            read(f1,s);
            ok:=verf(s);
            while (not eof(f1))and(ok=0) do
              begin
                read(f1,s);
                ok:=verf(s);

              end;
            if ok=1 then begin nr:=nr+1; nrc:=nrc+1; l:=1; end;
          end;
        read(f1,s);
      end;
  if verf(k)=1 then nrc:=nrc+1;
  if l=0 then writeln(f2,0)
  else writeln(f2,nr div nrc);
  close(f1);
  close(f2);
end.