Cod sursa(job #1817004)

Utilizator balazstasiTasi Balazs balazstasi Data 27 noiembrie 2016 11:42:12
Problema Text Scor 20
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.53 kb
Program Textual;

VAR
	f,g : Text;
	s, Aux	: String;
	Nr_Words,Nr_Letters,i : Integer;

BEGIN

	Assign(f,'text.in'); Reset(f);
	
	While Not(EoLn(f)) do
		Read(f,s);
		
	Aux := 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
	
	For i:=1 to Length(s)-1 do
		begin
			If ((s[i] = ' ') or (s[i] = '-')) and (pos(s[i+1],Aux) > 0) then Inc(Nr_Words);
			If pos(s[i],Aux) > 0 then Inc(Nr_Letters);
		end;
		
	Assign(g,'text.out'); Rewrite(g);
		
	Write(g,Nr_Letters div Nr_Words);
	
	Close(f); Close(g);

END.