Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace Array_Rotation
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] numArray = Console.ReadLine().Split().Select(int.Parse).ToArray();
- int numRotations = int.Parse(Console.ReadLine());
- int counterOne = numRotations - 1;
- int counterTwo = numArray.Length - 1;
- int[] switchedArray = new int[numArray.Length];
- for (int i = numArray.Length - 1; i >= 0; i--)
- {
- if (counterOne >= 0)
- {
- switchedArray[i] = numArray[counterOne];
- counterOne--;
- }
- else
- {
- switchedArray[i] = numArray[counterTwo];
- counterTwo--;
- }
- }
- Console.WriteLine(String.Join(" ", switchedArray));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement