Cod sursa(job #1089492)

Utilizator DjokValeriu Motroi Djok Data 21 ianuarie 2014 18:50:27
Problema Text Scor 40
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.83 kb
program p3;
  const lit=['A'..'Z','a'..'z'];
        spatiu=[' '];
        punct=['.'];
  var fi,fo:text;
      k,i,q:integer;
      s:string;
begin
  assign(fi,'text.in'); reset(fi);
  assign(fo,'text.out'); rewrite(fo);
  while not eoln(fi) do read(fi,s);
  close(fi);
  s:=' '+s+' '+'.'; k:=0;
  for i:=1 to length(s) do
  if not( s[i] in lit) and not(s[i] in punct) and not(s[i] in spatiu) then begin
                             delete(s,i,1);
                             insert(' ',s,i);
                             end;
  for i:=1 to length(s) do
  if (s[i]=' ') and (s[i+1]<>' ') then k:=k+1;
   for i:=1 to length(s) do
  if (s[i]=' ') and (s[i+1]='.') then k:=k-1;
  for i:=1 to length(s) do
  if s[i] in lit then q:=q+1;
  writeln(fo,trunc(q/k):0);
  writeln(fo,q);
  writeln(fo,k);


  close(fo);
end.