Skip to content

Instantly share code, notes, and snippets.

@VladimirYus
Created December 12, 2025 01:28
Show Gist options
  • Select an option

  • Save VladimirYus/82bb295634db171837bf539e4e749c95 to your computer and use it in GitHub Desktop.

Select an option

Save VladimirYus/82bb295634db171837bf539e4e749c95 to your computer and use it in GitHub Desktop.
ShiftingArrayValues
using System;
namespace ShiftingArrayValues
{
internal class Program
{
static void Main(string[] args)
{
int arraySize = 10;
int lowerNumberRandom = 0;
int upperNumberRandom = 10;
int userInput;
int firstNumber;
int[] numbers = new int[arraySize];
Random random = new Random();
for (int i = 0; i < numbers.Length; i++)
{
numbers[i] = random.Next(lowerNumberRandom, upperNumberRandom + 1);
Console.Write(numbers[i] + " ");
}
Console.WriteLine();
Console.Write("Укажите на сколько вы хотите сдвинуть значения влево: ");
userInput = Convert.ToInt32(Console.ReadLine());
userInput = userInput % numbers.Length;
for (int i = 0; i < userInput; i++)
{
firstNumber = numbers[0];
for (int j = 0; j < numbers.Length - 1; j++)
{
numbers[j] = numbers[j + 1];
}
numbers[numbers.Length - 1] = firstNumber;
}
for (int i = 0; i < numbers.Length; i++)
{
Console.Write(numbers[i] + " ");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment