a)
uses crt;
var a:array[1..100]of integer;
n,i,t:integer;
tbc:real;
begin
clrscr;
write('n='); readln(n);
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
t:=0;
for i:=1 to n do
t:=t+a[i];
tbc:=t/n;
writeln('trung binh cong cua day so la: ',tbc:4:2);
readln;
end.
b)
uses crt;
var a:array[1..100]of integer;
n,i,t:integer;
tbc:real;
begin
clrscr;
write('n='); readln(n);
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
t:=0; i:=1;
while i<=n do
begin
t:=t+a[i];
inc(i);
end;
tbc:=t/n;
writeln('trung binh cong cua day so la: ',tbc:4:2);
readln;
end.
A)
uses crt;
var a:array[1..100]of integer;
n,i,tong:integer;
begin
clrscr;
write('Nhap so n: '); readln(n);
for i:=1 to n do
begin
write('So thu ',i,': '); readln(a[i]);
end;
tong:= 0;
for i:=1 to n do
tong:=tong+a[i];
writeln('trung binh cong cua day so la: ',tong/n:0:2);
readln
end.
B)
uses crt;
var a:array[1..100]of integer;
n,i,tong:integer;
begin
clrscr;
write('Nhap so cac so: '); readln(n);
for i:=1 to n do
begin
write('So thu ',i,': '); readln(a[i]);
end;
tong:=0; i:=1;
while i <= n do
begin
tong:=tong + a[i];
i:= i + 1;
end;
writeln('trung binh cong cua day so la: ',tong/n:0:2);
readln;
end.