Cod sursa(job #601304)

Utilizator ctlin04UAIC.VlasCatalin ctlin04 Data 5 iulie 2011 21:03:34
Problema Text Scor 60
Compilator fpc Status done
Runda Arhiva de probleme Marime 1.35 kb
Program text_3;
 var ch:char;
   s:set of char;
  k,l,n,i,j,m,g:longint;
  fi,fo:text;
begin
 assign(fi,'text.in');
  reset(fi);
 assign(fo,'text.out');
  rewrite(fo);
 s:=['a'..'z','A'..'Z'];
 while not eof(fi) do begin
  read(fi,ch);
    if ch in s then inc(l)
     else if ch in ['0'..'9'] then inc(j)
      else if ch='-' then begin
                          if l>0 then inc(g)
                                   else g:=0;
                          if g>0 then inc(n);
                          end;
  if (ch=' ') or (ch in ['.','?','!',';']) then
   if (l>0) and (j=0) and (n=0) then begin
                                      inc(k);
                                      m:=m+l;
                                      l:=0;
                                      end
    else if j>0 then begin
                       l:=0;
                       j:=0;
                       end
    else if (l>0) and (j=0) and (n>0) then begin
                                            k:=k+1+n;
                                            m:=m+l;
                                            l:=0;
                                            n:=0;
                                            end;
              end;
    if k>1 then l:=m div k
        else if k=1 then l:=m
         else if k=0 then l:=0;
    writeln(fo,l);
   close(fo);
 end.