Câu 2:
uses crt;
var a:array[1..20]of integer;
i,n:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
for i:=1 to n do
write(a[i]:4);
readln;
end.
Câu 3:
uses crt;
var a:array[1..20]of integer;
i,n,t,t1,t2,t3:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
for i:=1 to n do
write(a[i]:4);
writeln;
t:=0;
t1:=0;
t2:=0;
for i:=1 to n do
begin
t:=t+a[i];
if a[i] mod 2=0 then t1:=t1+a[i]
else t2:=t2+a[i];
end;
writeln('Tong cua day la: ',t);
writeln('Tong cac so chan la: ',t1);
writeln('Tong cac so le la: ',t2);
t3:=0;
for i:=1 to n do
if a[i] mod 3=0 then t3:=t3+a[i];
writeln('Tong cac so chia het cho 3 la: ',t3);
readln;
end.