Cod sursa(job #598562)

Utilizator ctlin04UAIC.VlasCatalin ctlin04 Data 26 iunie 2011 13:49:52
Problema Text Scor 50
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.57 kb
Program paftenie;
 var a:array [1..100000] of char;
    fi, fo:text;
    i,j,k,n: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;
 for i:=1 to n do
  if a[i] in s then inc(k);
 for i:=1 to n-1 do
  if (a[i]=' ') and (a[i+1] in s) then inc(j);
 for i:=2 to n-1 do
  if (a[i]='-') and (a[i-1] in s) and (a[i+1] in s) then inc(j);
 assign(fo,'text.out');
 rewrite(fo);
  write(fo,trunc(k/j));
   close(fo);
end.