Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void Main(string[] args)
- {
- Random random = new Random();
- int minNumber = 5;
- int maxNumber = 10;
- int countElement = random.Next(minNumber, maxNumber);
- int[] array = new int[countElement];
- int userInput;
- int countShifts;
- Console.Write("Массив: ");
- for (int i = 0; i < array.Length; i++)
- {
- array[i] = random.Next(minNumber, maxNumber);
- Console.Write(array[i] + " ");
- }
- Console.WriteLine("\nВведите число для сдвига: ");
- userInput = Convert.ToInt32(Console.ReadLine());
- if (userInput > array.Length)
- countShifts = userInput % array.Length;
- else
- countShifts = userInput;
- if (countShifts != 0)
- {
- for (int i = 0; i < array.Length - countShifts; i++)
- {
- for (int j = 0; j < array.Length - 1; j++)
- {
- int tempNumber = array[j];
- array[j] = array[array.Length - 1];
- array[array.Length - 1] = tempNumber;
- }
- }
- }
- Console.WriteLine(string.Join(" ", array));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement