Cod sursa(job #38380)

Utilizator M@2Te4iMatei Misarca M@2Te4i Data 25 martie 2007 18:39:47
Problema Text Scor 70
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.93 kb
program text;

var s:string;
    l,c:integer;
    gasit:boolean;

procedure afisare;
var i:integer;
begin
assign(output,'text.out');
rewrite(output);
if c<>0 then
   i:=trunc(l/c)
   else i:=0;
write(i);
close(output);
end;

procedure procesare;
var i:integer;
begin
for i:=1 to length(s) do
    if (s[i] in ['A'..'Z','a'..'z']) then
       begin
       l:=l+1;
       gasit:=true;
       end
       else if (s[i-1] in ['A'..'Z','a'..'z']) and
               not (s[i] in ['A'..'Z','a'..'z']) and (l>=1) then
               begin
               inc(c);
               gasit:=false;
               end;
if s[length(s)]in ['A'..'Z','a'..'z']
   then c:=c+1;
end;

procedure citire;
begin
assign(input,'text.in');
reset(input);
gasit:=false;
while not eof do
      begin
      if gasit then
         c:=c-1;
      readln(s);
      procesare;
      end;
afisare;
close(input);
end;

begin
citire;
end.