Lời giải :
program hotrotinhoc;
var i,n : integer ;
a: array[1..32000] of real;
tbc,tb : real;
begin
write('Nhap so luong hoc sinh :'); readln(n);
for i:= 1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
tb:=0;
for i:= 1 to n do
begin
if a[i]<5 then write(a[i],' ');
tb:=tb+a[i];
tbc:=tb/n;
end;
writeln;
write('Diem trung binh cong cua cac ban hoc sinh la :',tbc);
readln
end.