-Tính tổng dãy chẳn lẻ
program ct;
uses crt;
var i,n,S,S1:integer;
A:array[1..100] of integer;
begin
clrscr;
write('nhap n:=');readln(n);
for i:=1 to n do
begin
write('nhap mang A[',i,']:=');readln(A[i]);
end;
S:=0; S1:=0;
for i:=1 to n do
if A[i] mod 2=0 then S:=S+A[i] else S1:=S1+A[i];
writeln('tong so chan la:',S);
writeln('tong so le la:',S1);
readln
end.
-kiểm trả số nguyên tố
program ct;
uses crt;
var i,n:integer;
A,D:array[1..100] of integer;
begin
clrscr;
write('nhap n:=');readln(n);
for i:=1 to n do
begin
write('nhap mang A[',i,']:=');readln(A[i]);
end;
for i:=1 to n do
begin
for j:=1 to A[i] do
if A[i] mod j=0 then D[i]:=D[i]+1;
if D[i]=2 then writeln(A[i],' la so nguyen to') else writeln(A[i],' khong la so nguyen to');
end;
readln
end.