引用了@的排列组合类
protected void Button1_Click(object sender, EventArgs e) { int r = Int32.Parse(intr.Text.Trim()); int[] arr=new int[6]; int i; for (i = 0; i < arr.Length; i++) { arr[i] = i + 1; } //求排列 Listlst_Permutation = web1.PermutationAndCombination .GetPermutation(arr, r); Response.Write("-----------------------------共有"+lst_Permutation.Count+"种排列方式-------------------------------------------------- "); foreach (int[] str in lst_Permutation) { for (int j = 0; j < r; j++) { Response.Write(str[j]); } Response.Write(" "); } Response.Write("------------------------------------------------------------------- "); } protected void Button2_Click(object sender, EventArgs e) { int r = Int32.Parse(intr.Text.Trim()); int[] arr = new int[6]; int i; for (i = 0; i < arr.Length; i++) { arr[i] = i + 1; } //求组合 List lst_Combination = web1.PermutationAndCombination .GetCombination(arr, r); Response.Write("-----------------------------共有" + lst_Combination.Count + "种排列方式-------------------------------------------- "); foreach (int[] str in lst_Combination) { for (int j = 0; j < r; j++) { Response.Write(str[j]); } Response.Write(" "); } Response.Write("------------------------------------------------------------------- "); }
输出排列结果。