Advertisement
dMundov

_04._Array_Rotation

Mar 9th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.75 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace _04._Array_Rotation
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             int[] normalArray = Console.ReadLine().Split(" ").Select(int.Parse).ToArray();
  11.             int numOfRotations = int.Parse(Console.ReadLine());
  12.             for (int i = 0; i < numOfRotations % normalArray.Length; i++)
  13.             {
  14.                 int tempNum = normalArray[0];
  15.                 for (int j = 1; j < normalArray.Length; j++)
  16.                 {
  17.                     normalArray[j - 1] = normalArray[j];
  18.                 }
  19.  
  20.                 normalArray[normalArray.Length - 1] = tempNum;
  21.             }
  22.  
  23.             Console.WriteLine(string.Join(" ", normalArray));
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement