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