Cod sursa(job #287331)

Utilizator cristinabCristina Brinza cristinab Data 24 martie 2009 18:52:05
Problema Text Scor 90
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.69 kb
{text}

var f,g:text;
    c:char;
    cuv:string;
    l,nr:longint;

begin

assign(f,'text.in'); reset(f);
assign(g,'text.out'); rewrite(g);

cuv:='';
nr:=0;
l:=0;

while not eof(f) do
      begin
      read(f,c);
      while upcase(c) in ['A'..'Z'] do
            begin
            cuv:=cuv+c;
            read(f,c);
            end;
      if cuv<>'' then
         begin
         l:=l+length(cuv);
         inc(nr);
         cuv:='';
         end;
      if upcase(c) in ['A'..'Z'] then cuv:=cuv+c;
      end;
if upcase(c) in ['A'..'Z'] then
begin
l:=l+length(cuv);
inc(nr);
end;

if nr=0 then writeln(g,0)
else writeln(g,trunc(l/nr),' ');

close(f);
close(g);
end.