Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int lenghtArray = 5;
- int[] arrayNumbers = new int[lenghtArray];
- Random random = new Random();
- int minRandomNumber = 1;
- int maxRandomNumber = 15;
- Console.WriteLine("Исходный массив: ");
- for (int i = 0; i < arrayNumbers.Length; i++)
- {
- arrayNumbers[i] = random.Next(minRandomNumber, maxRandomNumber + 1);
- Console.Write(arrayNumbers[i] + " ");
- }
- Console.Write("\n\nНа сколько сдвинуть массив влево: ");
- int inputMessage = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine($"\nСдвиг влево на: {inputMessage}");
- if (inputMessage % lenghtArray != 0)
- {
- for (int i = 0; i < inputMessage; i++)
- {
- int tempArrayNumber = arrayNumbers[0];
- for (int j = 0; j < arrayNumbers.Length - 1; j++)
- {
- arrayNumbers[j] = arrayNumbers[j + 1];
- }
- arrayNumbers[arrayNumbers.Length - 1] = tempArrayNumber;
- }
- }
- for (int i = 0; i < arrayNumbers.Length; i++)
- {
- Console.Write(arrayNumbers[i] + " ");
- }
- Console.WriteLine("\n");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement