Cod sursa(job #177787)

Utilizator DanielGGlodeanu Ioan Daniel DanielG Data 13 aprilie 2008 16:41:43
Problema Text Scor 100
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.68 kb
const m:set of char=['A'..'Z','a'..'z'];
var f:text;
c:char;
x,y,suma,nr:longint;
begin
assign(f,'text.in');reset(f);
x:=-1; y:=-1; suma:=0; nr:=0;
while not eof(f) do
begin
      read(f,c);
      if c in m then
         if x=-1 then begin
                      x:=0; y:=0;
                      end
                else inc(y)
      else begin
          if x<>-1 then begin
                        suma:=suma-x+y+1;
                        inc(nr);
                        end;
      x:=-1; y:=-1;
      end;
end;
if x<>-1 then
   begin
   suma:=suma-x+y+1;
   inc(nr);
   end;
close(f);
assign(f,'text.out');rewrite(f);
writeln(f,suma div nr);
close(f);
end.