begin
var n := ReadInteger('n =');
var a := ArrRandom(n, -99, 99);
a.Println;
var b := a.Where(p -> p > 0).Sorted.ToArray;
if b.Length > 0 then
var j := 0;
for var i := 0 to a.High do
if a[i] > 0 then begin
a[i] := b[j];
j += 1
end
else
a[i] := 0
end;
a.Println
end.
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
begin
var n := ReadInteger('n =');
var a := ArrRandom(n, -99, 99);
a.Println;
var b := a.Where(p -> p > 0).Sorted.ToArray;
if b.Length > 0 then
begin
var j := 0;
for var i := 0 to a.High do
if a[i] > 0 then begin
a[i] := b[j];
j += 1
end
else
a[i] := 0
end;
a.Println
end.