Ejemplo n.º 1
0
        static void GetCombinationTest()
        {
            int[] arr = new int[6];
            for (int i = 0; i < arr.Length; i++)
            {
                arr[i] = i + 1;
            }
            //求排列
            List <int[]> lst_Permutation = PermutationAndCombination <int> .GetPermutation(arr, 3);

            //求组合
            List <int[]> lst_Combination = PermutationAndCombination <int> .GetCombination(arr, 3);

            foreach (int[] item in lst_Permutation)
            {
                Console.WriteLine(String.Join(",", item));
            }
            Console.WriteLine("一共{0}种排列", lst_Permutation.Count());

            Action <int[]> act = actFun;

            void actFun(int[] ar)
            {
                Console.WriteLine(String.Join(",", ar));
            }

            lst_Combination.ForEach(x => actFun(x));
            Console.WriteLine("一共{0}种组合", lst_Combination.Count());

            Console.ReadLine();
        }
Ejemplo n.º 2
0
        static void LoadCombinationTest()
        {
            List <double> factors = new List <double> {
                1.3, 1.0
            };
            ConstantLoadType typeD = new ConstantLoadType(LoadTypes.D, factors);
            VariableLoadType typeL = new VariableLoadType(LoadTypes.L, 1.5, 0.7);
            VariableLoadType typeW = new VariableLoadType(LoadTypes.W, 1.5, 0.6);
            VariableLoadType typeT = new VariableLoadType(LoadTypes.T, 1.5, 0.6);

            VariableLoadType[] loadTypesL = { typeL, typeW, typeT };//可变荷载种类


            LoadCase CaseD   = new LoadCase(typeD, "DeadLoad", "这是恒载");
            LoadCase CaseL   = new LoadCase(typeL, "LiveLoad", "满跨活荷载");
            LoadCase CaseLl  = new LoadCase(typeL, "leftLiveLoad", "左跨活荷载");
            LoadCase CaseLr  = new LoadCase(typeL, "rightLiveLoad", "右跨活荷载");
            LoadCase CaseWx1 = new LoadCase(typeW, "Wx1", "x正向风荷载");
            LoadCase CaseWx2 = new LoadCase(typeW, "Wx2", "x负向风荷载");
            LoadCase CaseWy1 = new LoadCase(typeW, "Wy1", "y正向风荷载");
            LoadCase CaseWy2 = new LoadCase(typeW, "Wy2", "y负向风荷载");
            LoadCase CaseT1  = new LoadCase(typeT, "T1", "升温");
            LoadCase CaseT2  = new LoadCase(typeT, "T2", "降温");

            LoadCase[] cases = { CaseL, CaseLl, CaseLr, CaseWx1, CaseWx2, CaseWy1, CaseWy2 };//荷载单工况种类
            List <VariableLoadType[]> combinations = PermutationAndCombination <VariableLoadType> .GetCombination(loadTypesL, 1);

            int num = 0;

            foreach (VariableLoadType[] item in combinations)
            {
                Console.WriteLine("num = {0} ", num.ToString());
                num++;
                List <string> combnames = new List <string>();
                foreach (VariableLoadType casei in item)
                {
                    combnames.Add(casei.Type.ToString());
                }
                combnames.ForEach(x => Console.WriteLine(String.Join(",", x)));
            }
            Console.ReadLine();
        }