Skip to content

Instantly share code, notes, and snippets.

@unilecs
Created December 21, 2018 03:24
Show Gist options
  • Save unilecs/aada6fc4fd6a3cdcf92f85873b68d0b3 to your computer and use it in GitHub Desktop.
Save unilecs/aada6fc4fd6a3cdcf92f85873b68d0b3 to your computer and use it in GitHub Desktop.
Задача: Double Reverse
using System;
using System.Linq;
public class Program
{
public static void DoubleReverse(ref int[] arr, int ind_1, int ind_2, int ind_3, int ind_4)
{
while (ind_1 < ind_2)
{
int temp = arr[ind_1];
arr[ind_1] = arr[ind_2];
arr[ind_2] = temp;
ind_1++;
ind_2--;
}
while (ind_3 < ind_4)
{
int temp = arr[ind_3];
arr[ind_3] = arr[ind_4];
arr[ind_4] = temp;
ind_3++;
ind_4--;
}
}
public static void Main()
{
Console.WriteLine("UniLecs");
int n = 9;
int[] arr = Enumerable.Range(1, n).ToArray();
DoubleReverse(ref arr, 1, 4, 5, 8);
Console.WriteLine(string.Format("Answer = {0}", string.Join(" ", arr)));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment