Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Основы.Практика
- {
- class Program
- {
- static void Main()
- {
- int userInput;
- int temporaryNumber;
- int[] arrayNumber = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
- for (int i = 0; i < arrayNumber.Length; i++)
- {
- Console.Write(arrayNumber[i] + " ");
- }
- Console.Write($"\nВведите количество сдвигов влево, не превышающее {arrayNumber.Length}: ");
- userInput = Convert.ToInt32(Console.ReadLine());
- if(userInput % arrayNumber.Length == 0)
- {
- Console.WriteLine("Введеное число некорректно!");
- return;
- }
- while (userInput % arrayNumber.Length != 0)
- {
- for (int i = 1; i < arrayNumber.Length; i++)
- {
- temporaryNumber = arrayNumber[i];
- arrayNumber[i] = arrayNumber[i - 1];
- arrayNumber[i - 1] = temporaryNumber;
- }
- userInput--;
- }
- Console.Write("\nНовый массив: ");
- for (int i = 0; i < arrayNumber.Length; i++)
- {
- Console.Write(arrayNumber[i] + " ");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement