Advertisement
aspire12

04.ArrayRotation

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