Bài 1:
uses crt;
var a,b:array[1..100]of integer;
i,n,dem,j,kt,dem1:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
b[1]:=a[1];
dem:=1;
for i:=1 to n do
begin
kt:=0;
for j:=1 to dem do
if a[i]=b[j] then kt:=1;
if kt=0 then
begin
inc(dem);
b[dem]:=a[i];
end;
end;
for i:=1 to dem do
write(b[i]:4);
writeln;
for i:=1 to dem do
begin
dem1:=0;
for j:=1 to n do
if b[i]=a[j] then inc(dem1);
writeln(b[i],' xuat hien ',dem1,' lan');
end;
readln;
end.
Bài 2:
uses crt;
var a:array[1..100]of integer;
i,n: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] mod 2=0 then write(a[i]:4);
for i:=1 to n do
if a[i] mod 5=0 then write(a[i]:4);
for i:=1 to n do
if (a[i] mod 2<>0) and (a[i]<10) then write(a[i]:4);
readln;
end.