Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace CSLight
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- int[] array = new int[10];
- Random random = new Random();
- int tempValueElement;
- int lastTempValueElement;
- int userInput;
- int maxNumber = 10;
- int numberZero = 0;
- Console.WriteLine("Массив: ");
- for (int i = 0; i < array.Length; i++)
- {
- array[i] = random.Next(maxNumber);
- Console.Write(array[i] + " ");
- }
- Console.Write("\n\nУкажите шаг сдвига: ");
- userInput = Convert.ToInt32(Console.ReadLine());
- for (int i = 0; i < userInput; i++)
- {
- lastTempValueElement = array[array.Length - 1];
- array[array.Length - 1] = array[0];
- for (int j = array.Length - 1; j > numberZero; j--)
- {
- tempValueElement = lastTempValueElement;
- lastTempValueElement = array[j - 1];
- array[j - 1] = tempValueElement;
- }
- }
- foreach (int element in array)
- {
- Console.Write(element + " ");
- }
- Console.WriteLine("\n");
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement