Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace _04._Array_Rotation
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] normalArray = Console.ReadLine().Split(" ").Select(int.Parse).ToArray();
- int numOfRotations = int.Parse(Console.ReadLine());
- for (int i = 0; i < numOfRotations % normalArray.Length; i++)
- {
- int tempNum = normalArray[0];
- for (int j = 1; j < normalArray.Length; j++)
- {
- normalArray[j - 1] = normalArray[j];
- }
- normalArray[normalArray.Length - 1] = tempNum;
- }
- Console.WriteLine(string.Join(" ", normalArray));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement