Cod sursa(job #145479)

Utilizator vladddAntonio Vlad mihai vladdd Data 28 februarie 2008 20:49:44
Problema Text Scor 30
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.68 kb
program textul;
var f,g:text;
    c1,c2:char;
    lung,cuv,m:word;
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,c1,c2);
     lung:=0;
     if litera(c1) then inc(lung);
     cuv:=0;
     repeat
          if (litera(c1)=true) and (litera(c2)=false) then inc(cuv);
          if litera(c2) then inc(lung);
          c1:=c2;
          read(f,c2);
     until (c2='.') or (c2='?')or (c2='!');
     m:= lung div cuv;
     write(g,m);
     close(f);
     close(g);
end.