Cod sursa(job #210279)

Utilizator gabisabadacdswefwegzcv gabisabadac Data 27 septembrie 2008 11:07:12
Problema Text Scor 40
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.71 kb
program swastika;
var f,g:text;
    i,j,letters,words,word:integer;
    a:string;
 begin
  assign(f,'text.in'); reset(f);
  while (not eoln(f)) do
   begin
    read(f,a);
    for i:=1 to length(a) do
     begin
      if ((ord(a[i]) > 64) and (ord(a[i]) < 91)) or ((ord(a[i])>96) and (ord(a[i])<123)) then word:=word+1;
      if ((ord(a[i])<65) and (word>0)) or ((ord(a[i])>90) and (ord(a[i])<97) and (word>0)) or ((ord(a[i])>122) and (word>0)) then
       begin
        words:=words+1; word:=0;
       end;
      if ((ord(a[i])>64) and (ord(a[i])<91)) or ((ord(a[i])>96) and (ord(a[i])<123)) then letters:=letters + 1;
     end;
   end;
  close(f); assign(g,'text.out'); rewrite(g);
  write(g,letters div words); close(g);
 end.