Cod sursa(job #533959)

Utilizator guralivuion ion guralivu Data 14 februarie 2011 21:23:48
Problema Text Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.84 kb
program ff;
var f,g:text;
c:char;
nrc,ltot,lcur:integer;
ok:boolean;
begin
   assign(f,'text.in');
   reset(f);
   assign(g,'text.out');
   rewrite(g);
   nrc:=0; ltot:=0;
   ok:=false;
   while not eof(f) do
   begin
      read(f,c);
      if ((c>='a') and (c<='z')) or ((c>='A') and (c<='Z')) then
      begin
            lcur:=lcur+1;
            ok:=true;
      end
      else
      begin

        if ok then
                begin
                   inc(nrc);
                   ok:=false;
                   ltot:=lcur+ltot;
                   lcur:=0;
                end;
      end;

   end;
   if ((c>='a') and (c<='z')) or ((c>='A') and (c<='Z')) then
      if ok then
          begin
            ltot:=ltot+lcur;
            inc(nr);
          end;
   write(g,trunc(ltot/nrc));
   close(f);
   close(g);
end.