Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Study
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] array = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
- shuffleArray(array);
- for (int j = 0; j < array.Length; j++)
- {
- Console.WriteLine(array[j]);
- }
- Console.ReadKey();
- }
- public static void shuffleArray(int[] firstArray)
- {
- int lengthArray = firstArray.Length;
- Random rand = new Random();
- for (int i = 0; i < lengthArray; i++)
- {
- swap(firstArray, i, i + rand.Next(lengthArray - i));
- }
- }
- public static void swap(int[] array, int firstArray, int secondArray)
- {
- int temp = array[firstArray];
- array[firstArray] = array[secondArray];
- array[secondArray] = temp;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement