Cod sursa(job #383561)

Utilizator ionutz32Ilie Ionut ionutz32 Data 16 ianuarie 2010 21:01:58
Problema Text Scor 100
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.67 kb
var i,poz,sum,nrc:longint;
c:char;
f,g:text;
k:boolean;
begin
assign(f,'text.in');
assign(g,'text.out');
reset(f);rewrite(g);
while not eof(f) do
      begin
      inc(i);
      read(f,c);
      if ((c>='a') and (c<='z')) or ((c>='A') and (c<='Z')) then
         begin
         if k=false then
            poz:=i;
         k:=true;
         end
      else
          begin
          if k=true then
             begin
             inc(nrc);
             inc(sum,i-poz);
             end;
          k:=false;
          end;
      end;
if k=true then
   begin
   inc(nrc);
   inc(sum,i+1-poz);
   end;
write(g,trunc(sum/nrc));
close(f);close(g);
end.