예제 #1
0
        public void ShuffleList(List <int> lis)  //Shuffle supplied int list
        {
            int j = lis.Count;

            while (j > 1)
            {
                j--;
                int k    = SysRand.Next(j + 1);
                int temp = lis[k];
                lis[k] = lis[j];
                lis[j] = temp;
            }
        }
예제 #2
0
        public void ShuffleArray(int[] arr)   //Shuffle supplied int array
        {
            int j = arr.Length;

            while (j > 1)
            {
                j--;
                int k    = SysRand.Next(j + 1);
                int temp = arr[k];
                arr[k] = arr[j];
                arr[j] = temp;
            }
        }
예제 #3
0
        public void CountAndShuffleArray(int[] arr)   //Populate array with ascending numbers, then shuffle
        {
            for (int i = 0; i < arr.Length; i++)
            {
                arr[i] = i;
            }
            int j = arr.Length;

            while (j > 1)
            {
                j--;
                int k    = SysRand.Next(j + 1);
                int temp = arr[k];
                arr[k] = arr[j];
                arr[j] = temp;
            }
        }