Advertisement
SaNik74

Kansas city shuffle

Mar 27th, 2023 (edited)
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.83 KB | None | 0 0
  1. using System;
  2. using static System.Runtime.InteropServices.JavaScript.JSType;
  3.  
  4. internal class Program
  5. {
  6.     static void Main(string[] args)
  7.     {
  8.         Random random = new Random();
  9.         int[] numbers = new int[10];
  10.  
  11.         for (int i = 0; i < numbers.Length; i++)
  12.         {
  13.             numbers[i] = random.Next(1, 10);
  14.         }
  15.  
  16.         Shuffle(numbers);
  17.  
  18.         for (int i = 0; i < numbers.Length; i++)
  19.         {
  20.             Console.Write(numbers[i]);
  21.         }
  22.     }
  23.  
  24.     static void Shuffle(int[] array)
  25.     {
  26.         Random random = new Random();
  27.  
  28.         for (int i = 0; i < array.Length; i++)
  29.         {
  30.             int tempIndex = random.Next(array.Length);
  31.             int tempArray = array[tempIndex];
  32.             array[tempIndex] = array[i];
  33.             array[i] = tempArray;
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement