Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace IJunior
- {
- class Program
- {
- static void Main(string[] args)
- {
- Random random = new Random();
- int[] array = new int[30];
- int userInput;
- int temporary;
- for (int i = 0; i < array.Length; i++)
- {
- array[i] = random.Next(0, 100);
- Console.Write($"{array[i]} ");
- }
- Console.WriteLine();
- Console.Write("Введите на сколько позиций надо сдвинуть массив: ");
- userInput = Convert.ToInt32(Console.ReadLine());
- for (int i = 0; i < userInput; ++i)
- {
- int firstElement = array[0];
- for (int j = 1; j < array.Length; j++)
- {
- array[j - 1] = array[j];
- }
- array[array.Length - 1] = firstElement;
- }
- for (int i = 0; i < array.Length; i++)
- {
- Console.Write($"{array[i]} ");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement