// PascalABC.NET
begin
var n := ReadInteger('n =');
var a := ArrRandom(n, -99, 99);
a.Println;
if n.IsEven then
a := a[::2].Sorted.Interleave(a[1::2]).ToArray
else
var b := a[::2].Sorted;
var c := b.Last;
a := (b.Interleave(a[1::2]) + c).ToArray
end;
a.Println
end.
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
// PascalABC.NET
begin
var n := ReadInteger('n =');
var a := ArrRandom(n, -99, 99);
a.Println;
if n.IsEven then
a := a[::2].Sorted.Interleave(a[1::2]).ToArray
else
begin
var b := a[::2].Sorted;
var c := b.Last;
a := (b.Interleave(a[1::2]) + c).ToArray
end;
a.Println
end.