Phần khai báo bạn tự khia báo nha, mình làm từ Begin luôn
begin
write('Nhap so phan tu: '); readln(n);
for i:=1 to n do readln(A[i]);
//Sắp xếp giảm dần
for i:=1 to n-1 do
for j:=i+1 to n do if A[i]<A[j] then
begin
tam:=A[i]; A[i]:=A[j]; A[j]:=tam;
end;
write('a. Day sau khi sap xep giam dan la: ');
for i:=1 to n do write(A[i],' '); writeln;
//In các phần tử có giá trị tuyệt đối lớn nhất
max:=abs(A[1]);
for i:=2 to n do if abs(A[i])>max then max:=abs(A[i]);
write('b. Cac phan tu co gia tri tuyet doi lon nhat: ');
for i:=1 to n do if abs(A[i])=max then write(A[i],' '); writeln;
//In ra các số chính phương
write('c. Phan tu chinh phuong: ');
for i:=1 to n do if sqr(round(sqrt(A[i])))=A[i] then write(A[i],' '); writeln;
//In ra phần tử chính
dem:=0;
for i:=1 to n do
begin
xh:=0;
for j:=1 to n do if A[i]=A[j] then xh:=xh+1;
if xh>=n/2 then
begin
write('d. Phan tu chinh:',A[i]); dem:=dem+1;
end; if dem=1 then break;
end;
if dem=0 then write('d. Khong co phan tu chinh');
readln;
end.
chúc bạn học tốt