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(string[] args)
- {
- int[] array = new int[10];
- int quantityShiftSteps;
- int valueForMove;
- for (int i = 0; i < array.Length; i++)
- {
- array[i] = i+1;
- }
- Console.Write("Массив: ");
- foreach (var number in array)
- {
- Console.Write(number + " ");
- }
- Console.Write("\n\nВведите количество шагов сдвига влево: ");
- quantityShiftSteps = Convert.ToInt32(Console.ReadLine());
- for (int i = 0; i < quantityShiftSteps; i++)
- {
- for (int j = 1; j < array.Length; j++)
- {
- valueForMove = array[j - 1];
- array[j - 1] = array[j];
- array[j] = valueForMove;
- }
- }
- Console.Write("Массив со сдвигом в " + quantityShiftSteps + " шаг/шага/шагов: ");
- foreach (var number in array)
- {
- Console.Write(number + " ");
- }
- Console.WriteLine("\n");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement