Câu 3:
uses crt;
var n,i:byte;
a:array[1..200] of integer;
tich:longint;
BEGIN
clrscr;
write('Nhap N:'); readln(n);
tich:=1;
for i:=1 to n do
begin
write('Nhap a[',i,']:');
readln(a[i]);
if (a[i]>0) and (a[i] mod 3=0) then tich:=tich*a[i];
end;
write('Tich cac so chia het cho 3 la:',tich);
readln
END.
Câu 4:
uses crt;
var n,i:byte;
a:array[1..200] of integer;
tong:longint;
BEGIN
clrscr;
write('Nhap N:'); readln(n);
tong:=0;
for i:=1 to n do
begin
write('Nhap a[',i,']:');
readln(a[i]);
if a[i]>0 then
if (a[i] mod 3=0) or (a[i] mod 5=0) then tong:=tong+a[i];
end;
write('Tong cac so chia het cho 3 hoac 5 la:',tong);
readln
END.
Chúc bạn học tốt!