uses crt; var a:array[1..1000] of longint; n,i,d,s:integer; begin clrscr; s:=0;d:=0; write(‘Nhap so luong phan tu: ‘); readln(n); for i:=1 to n do begin write(‘Phan tu thu ‘,i,’: ‘); readln(a[i]); end; for i:=1 to n do if a[i] mod 2=0 then begin inc(s,a[i]); inc(d,1); end; write(‘Trung binh cong cac so chan: ‘,s/d:0:2); readln; end.
program trung_binh_chan;
uses crt;
var A:array[1..10000] of integer;
n,i,t,d:integer;
begin
clrscr;
write(‘Nhap n: ‘); readln(n);
t:=0; d:=0;
for i:=1 to n do
begin
write(‘Nhap so thu ‘,i,’: ‘); readln(A[i]);
if A[i] mod 2=0 then
begin
d:=d+1;
t:=t+A[i];
end;
end;
write(‘Trung binh cac so chan la: ‘,t/d:0:3);
readln;
end.
uses crt;
var a:array[1..1000] of longint;
n,i,d,s:integer;
begin
clrscr;
s:=0;d:=0;
write(‘Nhap so luong phan tu: ‘); readln(n);
for i:=1 to n do
begin
write(‘Phan tu thu ‘,i,’: ‘); readln(a[i]);
end;
for i:=1 to n do if a[i] mod 2=0 then
begin
inc(s,a[i]);
inc(d,1);
end;
write(‘Trung binh cong cac so chan: ‘,s/d:0:2);
readln;
end.