Cod sursa(job #144036)

Utilizator SILVER_BOY22Dalalau Alexandru SILVER_BOY22 Data 27 februarie 2008 07:54:55
Problema Text Scor 90
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.74 kb
program textul;
var f,g:text;
    c1,c2:char;
    lung,cuv,m:longint;

function litera(x:char):boolean;
begin
     if ((x>='a') and (x<='z'))or((x>='A') and (x<='Z')) then litera:=true
        else litera:=false;
end;

begin
     assign(f,'text.in');
     assign(g,'text.out');
     reset(f);
     rewrite(g);
     read(f,c2);  {primul caracter}
     lung:=0;
     if litera(c2) then inc(lung);
     cuv:=0;
     repeat
          c1:=c2;
          read(f,c2);
          if (litera(c1)=true) and (litera(c2)=false) then inc(cuv);
          if litera(c2) then inc(lung);
     until {(c2='.') or (c2='?')or (c2='!')or} eof(f);
     if cuv<>0 then m:= lung div cuv
        else m:=0;
     write(g,m);
     close(f);
     close(g);
end.