BubaLazi

Rotate Array of Strings

Jul 10th, 2017
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.59 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ArraysLab
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string[] arr = Console.ReadLine().Split(' ');
  14.             string[] reversed = new string[arr.Length];
  15.  
  16.             for(int i = 0; i < arr.Length - 1; i++)
  17.             {
  18.                 reversed[i + 1] = arr[i];
  19.             }
  20.             reversed[0] = arr[arr.Length - 1];            
  21.             Console.WriteLine(string.Join(" ",reversed));
  22.  
  23.         }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment