Advertisement
YavorGrancharov

Mirror_Image(copy)

Jul 6th, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.16 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace Mirror_Image
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             string[] input = Console.ReadLine().Split(' ').ToArray();
  12.  
  13.             while (true)
  14.             {
  15.                 string n = Console.ReadLine();
  16.                 if (n == "Print")
  17.                 {
  18.                     break;
  19.                 }
  20.                 int index = int.Parse(n);
  21.                 for (int i = 0; i < index / 2; i++)
  22.                 {
  23.                     string temp = input[i];
  24.                     input[i] = input[index - i - 1];
  25.                     input[index - i - 1] = temp;
  26.                 }
  27.                 Array.Reverse(input);
  28.                 for (int i = 0; i < (input.Length - 1 - index) / 2; i++)
  29.                 {
  30.                     string temp = input[i];
  31.                     input[i] = input[input.Length - 2 - index - i];
  32.                     input[input.Length - 2 - index - i] = temp;
  33.                 }
  34.                 Array.Reverse(input);
  35.             }
  36.             Console.WriteLine(string.Join(" ", input));
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement