Skip to content

Instantly share code, notes, and snippets.

@Attosius
Last active September 28, 2025 17:02
Show Gist options
  • Select an option

  • Save Attosius/8a47db9409444d402b548f7ac17c3a44 to your computer and use it in GitHub Desktop.

Select an option

Save Attosius/8a47db9409444d402b548f7ac17c3a44 to your computer and use it in GitHub Desktop.
ДЗ: Канзас сити шафл
using System;
namespace IJuniorTasks
{
internal class Program
{
static void Main(string[] args)
{
var arrayToSort = new[] {1, 2, 3, 4, 5};
WriteArray(arrayToSort);
Shuffle(arrayToSort);
Console.WriteLine();
WriteArray(arrayToSort);
Console.ReadKey();
}
public static void Shuffle(int[] array)
{
var random = new Random();
for (int i = 0; i < array.Length; i++)
{
var indexToChange = random.Next(array.Length);
var temp = array[i];
array[i] = array[indexToChange];
array[indexToChange] = temp;
}
}
public static void WriteArray(int[] array)
{
for (int i = 0; i < array.Length; i++)
{
Console.Write($"{array[i]} ");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment