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 ConsoleApp1
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] array = new int[10];
- for (int i = 0; i < array.Length; i++)
- {
- array[i] = i;
- }
- Shuffle(ref array, 3);
- for (int i = 0; i < array.Length; i++)
- {
- Console.Write(array[i] + " ");
- }
- Console.ReadKey();
- }
- static void Shuffle(ref int[] array, byte iterationCount = 1)
- {
- Random rand = new Random();
- int value;
- int randindex;
- for (int j = 0; j < iterationCount; j++)
- {
- for (int i = 0; i < array.Length; i++)
- {
- randindex = rand.Next(0, array.Length);
- value = array[i];
- array[i] = array[randindex];
- array[randindex] = value;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement