Cod sursa(job #38377)

Utilizator M@2Te4iMatei Misarca M@2Te4i Data 25 martie 2007 18:38:08
Problema Text Scor 10
Compilator fpc Status done
Runda Arhiva de probleme Marime 1.05 kb
program text;

type sir=array[1..500]of char;

var s:sir;
    l,c,n: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 n do
    if (s[i] in ['A'..'Z','a'..'z']) then
       begin
       l:=l+1;
       gasit:=true;
       end
       else if (l>=1) and (s[i-1] in ['A'..'Z','a'..'z']) and
               not (s[i] in ['A'..'Z','a'..'z']) then
               begin
               inc(c);
               gasit:=false;
               end;
if s[n]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;
      n:=0;
      while not eoln do
            begin
            inc(n);
            read(s[n]);
            end;
      procesare;
      end;
afisare;
close(input);
end;

begin
citire;
end.