Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace Сдвиг_значений_массива
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- int[] array = { 10, 20, 30, 40, 50, 60 };
- Console.WriteLine("Исходный массив: ");
- for (int i = 0; i < array.Length; i++)
- {
- Console.Write(array[i] + " ");
- }
- Console.WriteLine();
- Console.Write("Введите количество позиций сдвига: ");
- int shift = Convert.ToInt32(Console.ReadLine());
- for (int i = 0; i < shift; i++)
- {
- int temp = array[0];
- for (int j = 0; j < array.Length - 1; j++)
- {
- array[j] = array[j + 1];
- }
- array[array.Length - 1] = temp;
- }
- for (int i = 0; i < array.Length; i++)
- {
- Console.Write(array[i] + " ");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement