Cod sursa(job #88894)

Utilizator savimSerban Andrei Stan savim Data 4 octombrie 2007 18:59:11
Problema Text Scor 100
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.86 kb
var f1,f2:text;
    lc,nc,i:longint;
    t,q:char;
begin
     assign(f1,'text.in');
     assign(f2,'text.out');
     reset(f1);
     rewrite(f2);
     nc:=0;lc:=0;
     {numar de litere}
     while not eof(f1) do
     begin
          read(f1,t);
          if ((t>='a') and (t<='z')) or ((t>='A') and (t<='Z')) then inc(lc);
     end;
     {numar de cuvinte}
     reset(f1);
     read(f1,t);
     if ((t>='a') and (t<='z')) or ((t>='A') and (t<='Z')) then inc(nc);
     while not eof(f1) do
     begin
          read(f1,q);
          if (((q>='a') and (q<='z')) or ((q>='A') and (q<='Z'))) and
             (not(t in ['a'..'z'])) and (not(t in ['A'..'Z'])) then inc(nc);
          t:=q;
     end;
     if (lc<>0) and (nc=0) then nc:=nc+1;
     if nc=0 then writeln(f2,0)
             else writeln(f2,lc div nc);
     close(f1);
     close(f2);
end.