Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace CSLight_4._3
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] arr = { 1, 2, 3, 4, 5, 6, 7, 8 };
- Shuffle(arr);
- for (int i = 0; i < arr.Length; i++)
- {
- Console.Write(arr[i]);
- }
- }
- public static void Shuffle(int[] arr)
- {
- Random rand = new Random();
- for (int i = 0; i < arr.Length; i++)
- {
- int randIndex = rand.Next(i + 1);
- int tempVariable = arr[randIndex];
- arr[randIndex] = arr[i];
- arr[i] = tempVariable;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement