uses crt;
var n,i,j,t,k:byte;
a,b,c:array[1..1000] of longint;
function shh(n:longint):boolean;
var tong:longint;
begin
tong:=0;
for k:=1 to n div 2 do
if n mod k =0 then tong:=tong+k;
if tong=n then shh:=true else shh:=false;
end;
function snt(n:longint):boolean;
var dem:byte;
begin
dem:=0;
for k:=1 to n do
if n mod k=0 then dem:=dem+1;
snt:=dem=2;
end;
begin
clrscr;
write('nhap so phan tu cua day:');readln(n);
writeln('nhap day so nguyen:');
for i:=1 to n do
begin
write('a[',i,']=');readln(a[i]);
end;
j:=0; t:=0;
for i:=1 to n do
begin
if shh(a[i])=true then
begin
inc(j);
b[j]:=a[i];
end;
if snt(a[i])=true then
begin
inc(t);
c[t]:=a[i];
end;
end;
if j=0 then write('trong day khong co so hoan hao')
else
begin
writeln('day con gom cac so hoan hao la:');
for i:=1 to j do write(b[i],' ; ');
end;
writeln;
if t=0 then write('trong day khong co so nguyen to')
else
begin
writeln('day con gom cac so nguyen to la:');
for i:=1 to t do write(c[i],' ; ');
end;
readln;
end.
chúc bạn học tốt nhé!!