Advertisement
xotoi

Untitled

Oct 19th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.08 KB | None | 0 0
  1. using System;
  2.  
  3. namespace DZ_1
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int[] data = new int[1000];
  10.  
  11.             InitArray(data, 1);
  12.  
  13.             EvenReverse(data, 0);
  14.  
  15.             for (int i = 0; i < 1000; i++)
  16.             {
  17.                 Console.WriteLine(data[i]);
  18.             }
  19.             Console.ReadKey();
  20.         }
  21.         public static int[] EvenReverse(int[] array, int i)
  22.         {
  23.             if (i + 1 < array.Length)
  24.             {
  25.                 if ((i % 2) == 0)
  26.                 {
  27.                     int temp = array[i];
  28.                     array[i] = array[i + 1];
  29.                     array[i + 1] = temp;
  30.                 }
  31.                 i++;
  32.                 i++;
  33.                 EvenReverse(array, i);
  34.             }
  35.             return array;
  36.         }
  37.         public static int[] InitArray(int[] array, int i)
  38.         {
  39.             if (i < array.Length)
  40.             {
  41.                 array[i] = i++;
  42.                 InitArray(array, i);
  43.             }
  44.             return array;
  45.         }
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement