Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Task27._1
- {
- class Program
- {
- static void Main(string[] args)
- {
- Random random = new Random();
- string userInput;
- int minValue = 0;
- int maxValue = 11;
- int valueShifts;
- int bufferValue;
- int step = 1;
- int valueCountArray = random.Next(step, maxValue);
- int[] array = new int[valueCountArray];
- int endIndex = valueCountArray - step;
- for (int i = minValue; i < array.Length; i++)
- {
- array[i] = random.Next(minValue, maxValue);
- Console.Write(array[i] + " ");
- }
- Console.Write("\nВведите количество сдвигов влево: ");
- userInput = Console.ReadLine();
- valueShifts = Convert.ToInt32(userInput);
- for (int i = minValue; i < valueShifts; i++)
- {
- bufferValue = array[minValue];
- for (int j = minValue; j < array.Length - step; j++)
- {
- array[j] = array[j + step];
- }
- array[endIndex] = bufferValue;
- }
- for (int i = minValue; i < array.Length; i++)
- {
- Console.Write(array[i] + " ");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement