Tham khảo:
Ý đầu tiên :
uses crt;
var a:array[1..100]of integer;
i,n,j,kt: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
if a[i]>1 then
begin
kt:=0;
for j:=2 to trunc(sqrt(a[i])) do
if a[i] mod j=0 then kt:=1;
if kt=0 then write(a[i]:4);
end;
readln;
end.
Ý thứ 2:
Program Project1;
var a:array [1..100] of integer;
n, i: integer;
le: integer;
begin
write('Nhap so phan tu co trong mang: '); readln(n);
for i:=1 to n do
begin
write('Nhap vao phan tu thu A[',i,']: '); readln(A[i]);
end;
le:=0;
for i:=1 to n do
begin
if (A[i] mod 2 <> 0) then
le:=le+A[i];
end;
writeln('Tong cac phan tu le la ', le);
readln;
end.