Cod sursa(job #139674)

Utilizator 7RaduRadu Antohi 7Radu Data 20 februarie 2008 15:23:42
Problema Text Scor 20
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.98 kb
program Text_1;
const
   abc : string = ('abcdefghjiklmnopqrstuvwxyzABCDEFGHJIKLMNOPQRSTUVWXYZ');
var
   Fl : text;
   s : string;
   c : string[1];
   n, i, j, k, n1, s1, s2, n2, s_tot: integer;

function cuvint(s1:string):boolean;
begin
   cuvint := false;
   if length(s1) = 0 then
      exit;
   for i := 1 to length(s1) do
      if pos(s1[i],abc) = 0 then
         exit;
      cuvint := true;
end;
begin
   assign(fl,'text.in');
   reset(fl);
   c := '';
   while not eof(Fl) do
     begin
        s := s + c;
        read(fl,c);
        if ((c = ' ') or (c = '-') or (c = '!') or (c = ',') or (c = '?')) then
           begin
              if cuvint(s) then
                 begin
                    n2 := n2 + 1;
                    n1 := n1 + length(s);
               end;
              s := '';
              c := '';
           end;
     end;
   close(fl);

   assign(fl,'text.out');
   rewrite(fl);
   writeln(fl,n1 div n2);
   close(fl);
end.