コード例 #1
0
        /// <summary>
        /// 初始化15选1-6的组合
        /// </summary>
        /// <param name="dt"></param>
        private void SetCom15(DataTable dt)
        {
            int[] arr = GetArr(dt, 15);
            step3.ComStore15_1.Clear();
            step3.ComStore15_2.Clear();
            step3.ComStore15_3.Clear();
            step3.ComStore15_4.Clear();
            step3.ComStore15_5.Clear();
            step3.ComStore15_6.Clear();
            //计算15选1-6的所有组合
            for (int i = 1; i < 7; i++)
            {
                //求组合
                List <int[]> lstCombination = PermutationAndCombination <int> .GetCombination(arr, i);

                switch (i)
                {
                case 1:
                    SetCom(lstCombination, false, step3.ComStore15_1);
                    break;

                case 2:
                    SetCom(lstCombination, false, step3.ComStore15_2);
                    break;

                case 3:
                    SetCom(lstCombination, false, step3.ComStore15_3);
                    break;

                case 4:
                    SetCom(lstCombination, false, step3.ComStore15_4);
                    break;

                case 5:
                    SetCom(lstCombination, false, step3.ComStore15_5);
                    break;

                case 6:
                    SetCom(lstCombination, false, step3.ComStore15_6);
                    break;
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// 将号码组合并分组
        /// </summary>
        /// <param name="nums"></param>
        /// <returns></returns>
        public void SetAllGroup(ListBox.ObjectCollection nums)
        {
            step1.Group.Clear();
            //获取组数计算组合
            int[]        arr            = GetArr(nums.Count);
            List <int[]> lstCombination = PermutationAndCombination <int> .GetCombination(arr, 4);

            int nIndex = 0;

            //根据下标将索引转换成号码组
            foreach (var item in lstCombination)
            {
                nIndex++;
                string[] value = new string[4];
                for (int i = 0; i < item.Length; i++)
                {
                    value[i] = Convert.ToString(nums[item[i]]);
                }
                step1.Group.TryAdd(nIndex, value);
            }
        }
コード例 #3
0
        /// <summary>
        /// 终极过滤
        /// </summary>
        /// <param name="dic"></param>
        private void FinallFilter(ConcurrentDictionary <string, int[]> dic, int length)
        {
            //先找到不存在的号码
            int[]         arr         = GetArr(33);
            List <int>    lstnotexist = new List <int>();
            List <string> lsttemp     = new List <string>();
            string        strtemp     = "";

            int[] outvalue = null;
            foreach (var item in dic)
            {
                for (int i = 1; i <= arr.Length; i++)
                {
                    if (!item.Value.Contains(i))
                    {
                        lstnotexist.Add(i);
                    }
                }
                //计算不存在的所有组合
                List <int[]> lstCombination = PermutationAndCombination <int> .GetCombination(lstnotexist.ToArray(), 6 - length);

                int[] nkeys = new int[6];
                //数组合并
                foreach (int[] value in lstCombination)
                {
                    nkeys = item.Value.Concat(value).ToArray();
                    Array.Sort(nkeys);
                    for (int k = 0; k < nkeys.Length; k++)
                    {
                        strtemp += nkeys[k].ToString().PadLeft(2, '0') + " ";
                    }
                    strtemp = strtemp.Substring(0, strtemp.Length - 1);
                    lsttemp.Add(strtemp);
                    strtemp = "";
                    lstnotexist.Clear();
                }
                Parallel.ForEach(lsttemp, key => { store.Store.TryRemove(key, out outvalue); });
                lsttemp.Clear();
            }
        }