public static void comb_unrank_test() //****************************************************************************80 // // Purpose: // // COMB_UNRANK_TEST tests COMB_UNRANK. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 11 October 2006 // // Author: // // John Burkardt // { const int N = 5; int[] a = new int[N]; int i; const int m = 10; int rank; string cout; int cnk = typeMethods.i4_choose(m, N); Console.WriteLine(""); Console.WriteLine("COMB_UNRANK_TEST"); Console.WriteLine(" COMB_UNRANK returns a combination of N things"); Console.WriteLine(" out of M, given the lexicographic rank."); Console.WriteLine(""); Console.WriteLine(" The total set size is M = " + m + ""); Console.WriteLine(" The subset size is N = " + N + ""); Console.WriteLine(" The number of combinations of N out of M is " + cnk + ""); Console.WriteLine(""); Console.WriteLine(" Rank Combination"); Console.WriteLine(""); for (rank = 1; rank <= 3; rank++) { Comb.comb_unrank(m, N, rank, ref a); cout = " " + rank.ToString().PadLeft(3) + " "; for (i = 0; i < N; i++) { cout += a[i].ToString().PadLeft(4) + " "; } Console.WriteLine(cout); } for (rank = 6; rank <= 8; rank++) { Comb.comb_unrank(m, N, rank, ref a); cout = rank.ToString().PadLeft(3) + " "; for (i = 0; i < N; i++) { cout += a[i].ToString().PadLeft(4) + " "; } Console.WriteLine(cout); } for (rank = 250; rank <= 252; rank++) { Comb.comb_unrank(m, N, rank, ref a); cout = " " + rank.ToString().PadLeft(3) + " "; for (i = 0; i < N; i++) { cout += a[i].ToString().PadLeft(4) + " "; } Console.WriteLine(cout); } }