Cod sursa(job #678051)

Utilizator smotruSergiu Falcusan smotru Data 10 februarie 2012 22:39:00
Problema Text Scor 90
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.69 kb
program text_infoarena;
type sir = array[1..100000] of char;
var a:sir;
    i,n:longint;
    f,g:text;
    lungime,nr_cuvinte:integer;

begin
  assign(f,'text.in'); reset(f);
  i:=1;
  while not eof(f) do
  begin
    read(f,a[i]);
    inc(i);
  end;
  close(f);
  n:=i-1;
  for i:=1 to n do begin
    a[i]:=upcase(a[i]);
    if not (a[i] in ['A'..'Z','0'..'9']) then a[i]:=' ';
  end;

  nr_cuvinte:=0;
  lungime:=0;
  for i:=1 to n do begin
    if (a[i] in ['A'..'Z','0'..'9']) then inc(lungime);
    if ((a[i] in ['A'..'Z','0'..'9']) and (a[i+1]=' ')) then inc(nr_cuvinte);
  end;

  assign(g,'text.out'); rewrite(g);
  write(g,lungime div nr_cuvinte);
  close(g);
end.