Advertisement
Fle2x

Untitled

May 5th, 2020
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.54 KB | None | 0 0
  1. using System;
  2.  
  3.  
  4. public class Example
  5. {
  6.     public static void Main()
  7.     {
  8.         int[] array = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
  9.         Shuffle(array);
  10.         Console.ReadKey();
  11.     }
  12.     static void Shuffle(int[] array)
  13.     {
  14.         Random random = new Random();
  15.        
  16.         for (int i = 0; i < array.Length; i++)
  17.         {
  18.             int j = random.Next(array.Length);
  19.             array[i] = j;
  20.         }
  21.  
  22.         for (int i = 0; i < array.Length; i++)
  23.         {
  24.             Console.WriteLine(array[i]);
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement