Pagini recente » Cod sursa (job #2988701) | Cod sursa (job #1104354) | Cod sursa (job #1942067) | Cod sursa (job #615584) | Cod sursa (job #601340)
Cod sursa(job #601340)
program texte;
var s:string;
i,j,n,l,k,m:longint;
fi,fo:text;
simboluri,litere:set of char;
ch:char;
begin
assign(fi,'text.in');
reset(fi);
assign(fo,'text.out');
rewrite(fo);
litere:=['a'..'z','A'..'Z'];
simboluri:=[chr(0)..chr(127)]-litere;
while not eof(fi) do
begin
read(fi,ch);
if ch<>' ' then s:=s+ch
else if length(s)>0 then
for i:=1 to length(s) do
if s[i] in litere then inc(l)
else if (s[i]='-') and (l>0) then inc(n)
else if s[i] in simboluri-['-',',','.','?','!',';'] then inc(j);
if (l>0) and (j=0) and (n=0) then begin
inc(k);
m:=m+l;
l:=0;
end;
if (l>0) and (j=0) and (n>0) then begin
k:=k+1+n;
m:=m+l;
l:=0;
n:=0;
end;
if j>0 then begin
l:=0;
j:=0;
n:=0;
end;
end;
if eof(fi) then begin
if length(s)>0 then
for i:=1 to length(s) do
if s[i] in litere then inc(l)
else if (s[i]='-') and (l>0) then inc(n)
else if s[i] in simboluri-['-',',','.','?','!',';'] then inc(j);
if (l>0) and (j=0) and (n=0) then begin
inc(k);
m:=m+l;
l:=0;
end;
if (l>0) and (j=0) and (n>0) then begin
k:=k+1+n;
m:=m+l;
l:=0;
n:=0;
end;
if j>0 then begin
l:=0;
j:=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;
write(fo,l);
close(fo);
end.