Bài 2:
program bt;
uses crt;
var i, n, s : integer;
a : array[1..100] of integer;
begin
clrscr;
write('Nhap so so nguyen: '); readln(n);
for i:=1 to n do begin
write('Nhap so thu ',i,': '); readln(a[i]);
end;
s := 0;
write('Day so vua nhap la: ');
for i:=1 to n do begin
write(a[i],', ');
s := s + a[i];
end;
writeln;
writeln('Tong cac so trong day so la ',s);
writeln('Trung binh cong cac so trong day so la ',s/n:0:2);
readln
end.
Bài 3:
program bt;
uses crt;
var i, n, s, d : integer;
a : array[1..100] of integer;
begin
clrscr;
write('Nhap so so nguyen: '); readln(n);
for i:=1 to n do begin
write('Nhap so thu ',i,': '); readln(a[i]);
end;
s := 0; d := 0;
for i:=1 to n do if (a[i] > 10) and (a[i] < 20) then begin
d := d + 1;
s := s + a[i];
end;
writeln('Co ',d,' so nho hon 10 va lon hon 20');
write('Tong cac so lon hon 10 va be hon 20 la ',s);
readln
end.