Skip to content

Instantly share code, notes, and snippets.

@MagSosiq
Last active July 3, 2024 19:21
Show Gist options
  • Save MagSosiq/4e265c0047a5a6d4f727b060f1016a46 to your computer and use it in GitHub Desktop.
Save MagSosiq/4e265c0047a5a6d4f727b060f1016a46 to your computer and use it in GitHub Desktop.
using System;
using System.Text;
namespace HW1
{
internal class Program
{
static void Main(string[] args)
{
Console.InputEncoding = Encoding.Unicode;
Console.OutputEncoding = Encoding.Unicode;
int[] array = { 1, 2, 3, 4, 5 };
Console.WriteLine("Введите количество позиций для сдвига влево:");
int userInput = int.Parse(Console.ReadLine());
int arrayLength = array.Length;
userInput = userInput % arrayLength;
for (int i = 0; i < userInput; i++)
{
int firstElement = array[0];
for (int j = 1; j < arrayLength; j++)
{
array[j - 1] = array[j];
}
array[arrayLength - 1] = firstElement;
}
for (int i = 0; i < array.Length; i++)
{
if (i > 0)
{
Console.Write(", ");
}
Console.Write(array[i]);
}
Console.WriteLine();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment