program SortOddNumbersDescending; var a: array[1..100] of integer; n, i, j, temp: integer; begin writeln('Enter the number of elements in the array:'); readln(n);
writeln('Enter the elements of the array:'); for i := 1 to n do begin readln(a[i]); end;
// Sort odd numbers in descending order for i := 1 to n do begin if (a[i] mod 2 <> 0) then begin for j := i+1 to n do begin if (a[j] mod 2 <> 0) and (a[j] > a[i]) then begin temp := a[j]; a[j] := a[i]; a[i] := temp; end; end; end; end;
// Output the sorted array writeln('Sorted array with odd numbers in descending order:'); for i := 1 to n do begin write(a[i], ' '); end; end.
program SortOddNumbersDescending;
var
a: array[1..100] of integer;
n, i, j, temp: integer;
begin
writeln('Enter the number of elements in the array:');
readln(n);
writeln('Enter the elements of the array:');
for i := 1 to n do
begin
readln(a[i]);
end;
// Sort odd numbers in descending order
for i := 1 to n do
begin
if (a[i] mod 2 <> 0) then
begin
for j := i+1 to n do
begin
if (a[j] mod 2 <> 0) and (a[j] > a[i]) then
begin
temp := a[j];
a[j] := a[i];
a[i] := temp;
end;
end;
end;
end;
// Output the sorted array
writeln('Sorted array with odd numbers in descending order:');
for i := 1 to n do
begin
write(a[i], ' ');
end;
end.