Cod sursa(job #600734)

Utilizator ctlin04UAIC.VlasCatalin ctlin04 Data 2 iulie 2011 23:19:39
Problema Text Scor 40
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.83 kb
Program paftenie;
 var a:array [1..100000] of char;
    fi, fo:text;
    i,j,k,n,l:longint;
    s:set of char;
begin
 assign(fi,'text.in');
  reset(fi);
  i:=2;  a[1]:=' ';
   s:=['A'..'Z','a'..'z'];
   while not eof(fi) do begin
    read(fi,a[i]);
    inc(i);
    end;
 n:=i-1;
 i:=1;
 while i<=n do begin
  if a[i]=' ' then k:=i;
   if a[i] in s then inc(l)
     else if (a[i] in ['0'..'9']) then begin
           l:=l-i+k+1;
           dec(j);
            repeat
            if i<n-1 then
                         inc(i);
              until (a[i+1]=' ') or (i=n);
               end
        else if (a[i]=' ') and (a[i+1] in s) then inc(j);
  if (a[i]='-') and (a[i-1] in s) and (a[i+1] in s) then inc(j);
    inc(i);
  end;
 assign(fo,'text.out');
 rewrite(fo);
  write(fo,trunc(l/j));
   close(fo);
end.