Advertisement
LeRoY_Go

Untitled

Feb 2nd, 2022
880
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.04 KB | None | 0 0
  1. using System;
  2.  
  3. namespace C_Sharp_Junior
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             Random random = new Random();
  10.             string userInput = "";
  11.             int[] array = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
  12.             while (userInput != "exit")
  13.             {
  14.                 ShowConclusion(array);
  15.                 Shuffle(array, random);
  16.                 userInput = Console.ReadLine();
  17.             }
  18.         }
  19.  
  20.         static void Shuffle(int[] array, Random random)
  21.         {
  22.             for (int i = 0; i < array.Length; i++)
  23.             {
  24.                 int randomElement = random.Next(i);
  25.                 int indexElement = array[i];
  26.                 array[i] = array[randomElement];
  27.                 array[randomElement] = indexElement;
  28.             }
  29.         }
  30.  
  31.         static void ShowConclusion(int[] arrayValue)
  32.         {
  33.             foreach (var ItemValue in arrayValue)
  34.             {
  35.                 Console.Write(ItemValue + " ");
  36.             }
  37.         }
  38.  
  39.  
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement