uses crt;
var a:array[1..100]of integer;
i,n,k,t:integer;
begin
clrscr;
write('n='); readln(n);
if (0<n) and (n<=100) then
begin
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
write('k='); readln(k);
t:=0;
for i:=1 to n do
if a[i] mod k=0 then t:=t+a[i];
writeln('tong cac so chia het cho ',k,' trong day la: ',t);
end
else writeln('vui long nhap lai n');
readln;
end.
program an_danh;
uses crt;
var n,k,i,tong:integer;
a: array [1..100] of integer;
begin
clrscr;
repeat
write('Nhap N: ');readln(n);
if n > 100 then
begin
write('Hay nhap so nho hon 100');
delay(2000);
clrscr;
end;
until n <= 100;
for i:= 1 to n do
begin
write('Nhap phan tu thu ',i,': ');
readln(a[i]);
end;
write('Nhap k: ');readln(k);
tong:= 0;
for i:= 1 to n do
if a[i] mod k = 0 then tong:= tong + a[i];
write('Tong cac so chia het cho ',k,' la: ',tong);
readln
end.