Cod sursa(job #291028)

Utilizator lsorin_94Lodoaba Sorin lsorin_94 Data 29 martie 2009 11:47:14
Problema Text Scor 40
Compilator fpc Status done
Runda The Beginners Marime 0.8 kb
program cuvinte;
var i,l,n,med:longint;
    a:string;
    f:text;
begin
  assign(f,'text.in');
  reset(f);
  read(f,a);
  l:=0;
  for i:=1 to length(a) do
    begin
      if (a[i]>='a') and (a[i]<='z')
        then l:=l+1;
      if (a[i]>='A') and (a[i]<='Z')
        then l:=l+1;
      if (a[i]>'Z') and (a[i]<'a')
        then a[i]:=' ';
      if (a[i]<'A') and (a[i]>=chr(1))
        then a[i]:=' ';
    end;
  for i:=1 to length(a)-1 do
    begin
      if a[i]=' '
        then if a[i]=a[i+1]
               then delete(a,i,1);
    end;
  if a[1]=' ' then delete(a,1,1);
  if a[length(a)]=' ' then delete(a,length(a),1);
  n:=0;
  for i:=1 to length(a) do
    if a[i]=' ' then n:=n+1;
  med:=l div (n+1);
  assign(f,'text.out');
  rewrite(f);
  write(f,med);
  close(f);
end.