Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Homework5
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] numbers = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
- Shuffle(numbers);
- }
- static void Shuffle(int[] inputArray)
- {
- Random random = new Random();
- for (int i = inputArray.Length-1; i >= 0; i--)
- {
- int randomIndex = random.Next(0, i + 1);
- int tempValue = inputArray[i];
- inputArray[i] = inputArray[randomIndex];
- inputArray[randomIndex] = tempValue;
- Console.Write(inputArray[i] + " ");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment