https://pastein.ru/t/TO

  скопируйте уникальную ссылку для отправки


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication7
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] arr = { 1, -4, 2, 1, -5, -9, -2, 5};
            Queue<int> q0 = new Queue<int>();
            Queue<int> q1 = new Queue<int>();
            for (int k = 0; k < sizeof(int)*8; k++)
            {
                foreach (int x in arr)
                {
                    if (((x>>k) & 1)==0)
                    {
                        q0.Enqueue(x);
                    }
                    else
                    {
                        q1.Enqueue(x);
                    }
                }
                int i = 0;
                while (q0.Count != 0)
                {
                    arr[i++] = q0.Dequeue();
                }
                while (q1.Count != 0)
                {
                    arr[i++] = q1.Dequeue();
                }
            }
            foreach (int x in arr)
            {
                Console.Write($"{x}  ");
            }
            Console.WriteLine();
            for (int i = 0; i < (arr.Length / 4); i++)
            {
                int test1 = arr[i];
                arr[i] = arr[(arr.Length / 2) - i - 1];
                arr[(arr.Length / 2) - i - 1] = test1;
                int test2 = arr[(arr.Length) / 2 + i];
                arr[(arr.Length) / 2 + i] = arr[arr.Length - i - 1];
                arr[arr.Length - i - 1] = test2;
            }
            for (int i = 0, j = arr.Length - 1; i < j; i++, j--)
            {

            }
                foreach (int x in arr)
            {
                Console.Write($"{x}  ");
            }
            Console.WriteLine();
            for (int i = 0; i < (arr.Length / 2); i++)
            {
                int test1 = arr[i];
                arr[i] = arr[arr.Length - i - 1];
                arr[arr.Length - i - 1] = test1;
            }
            foreach (int x in arr)
            {
                Console.Write($"{x}  ");
            }
            Console.ReadKey();
        }
    }
}