Advertisement
Guest User

Untitled

a guest
Feb 2nd, 2024
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.47 KB | None | 0 0
  1. using System.Buffers;
  2.  
  3. namespace ArratRotatiom
  4. {
  5.     internal class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int[] arr = Console.ReadLine()
  10.                 .Split()
  11.                 .Select(int.Parse)
  12.                 .ToArray();
  13.             int n = int.Parse(Console.ReadLine());
  14.             n %= arr.Length;
  15.             int count = n;
  16.             int[] arr2 = new int[arr.Length];
  17.  
  18.             if (arr.Length == 1)
  19.             {
  20.                 Console.WriteLine(arr[0]);
  21.                 return;
  22.             }
  23.  
  24.  
  25.             //if (n > arr.Length)
  26.             //{
  27.             //    for (int i = 0; i < n - arr.Length; i++)
  28.             //    {
  29.             //
  30.             //        arr2[arr.Length - i - 1] = arr[i];
  31.             //    }
  32.             //    count = 0;
  33.             //    for (int i = n - arr.Length; i < arr.Length; i++)
  34.             //    {
  35.             //        arr2[count] = arr[i];
  36.             //        count++;
  37.             //    }
  38.             //    Console.WriteLine(string.Join(" ", arr2));
  39.             //    return;
  40.             //}
  41.             for (int i = 0; i < n; i++)
  42.             {
  43.  
  44.                 arr2[arr.Length - count] = arr[i];
  45.                 count--;
  46.             }
  47.             count = 0;
  48.             for (int i = n; i < arr.Length; i++)
  49.             {
  50.                 arr2[count] = arr[i];
  51.                 count++;
  52.             }
  53.  
  54.             Console.WriteLine(string.Join(" ", arr2));
  55.         }
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement