Var n,i,j,c:integer; ar:array of integer; begin readln(n); setlength(ar,n); for i:=0 to n-1 do readln(ar[i]); for i:=0 to n-2 do for j:=i+1 to n-1 do if ar[i]<ar[j] then begin c:=ar[i]; ar[i]:=ar[j]; ar[j]:=c; end; writeln; writeln('Final array:'); for i:=0 to n-1 do write(ar[i]:4); end.
Пример ввода: 5 2 4 6 1 2 Пример вывода: Final array: 6 4 2 2 1
Var
n,i,j,c:integer;
ar:array of integer;
begin
readln(n);
setlength(ar,n);
for i:=0 to n-1 do
readln(ar[i]);
for i:=0 to n-2 do
for j:=i+1 to n-1 do
if ar[i]<ar[j] then
begin
c:=ar[i];
ar[i]:=ar[j];
ar[j]:=c;
end;
writeln;
writeln('Final array:');
for i:=0 to n-1 do
write(ar[i]:4);
end.
Пример ввода:
5
2
4
6
1
2
Пример вывода:
Final array:
6 4 2 2 1