Cod sursa(job #291335)

Utilizator inlinestunter19Aab Bba inlinestunter19 Data 29 martie 2009 17:59:36
Problema Text Scor 100
Compilator fpc Status done
Runda The Beginners Marime 0.76 kb
var a:char;
    s: string;
    f,g:Text;
    k,cl,cc:longint;
   v:array[1..52] of char;
procedure gen_v;
var i:char;
begin
k:=0;
for i:='a' to 'z' do
begin
k:=k+1;
v[k]:=i;
end;
for i:='A' to 'Z' do
begin
k:=k+1;
v[k]:=i;
end;
end;
function find(x:char):boolean;
var i:integer;
    ok:boolean;
begin
ok:=false;
i:=1;
while (ok=false) and (i<=k) do
begin
if v[i]=x then
ok:=true;
i:=i+1;
end;
find:=ok;
end;
BEGIN
assign(f,'text.in');
reset(f);
gen_v;

cl:=0;
cc:=0;

while not eof(f) do
begin
 s:='';
 reaD(f,a);
 while find(a) do
 begin
  s:=s+a;
  cl:=cl+1;
  read(f,a);
 end;
 if (not find(a)) and(s<>'') then cc:=cc+1;
end;

assign(g,'text.out');
rewrite(g);
writeln(g,trunc(cl/cc));
close(g);
close(f);
END.