public static void catalan_test() //****************************************************************************80 // // Purpose: // // CATALAN_TEST tests CATALAN. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 07 November 2012 // // Author: // // John Burkardt // { int c = 0; int n = 0; Console.WriteLine(""); Console.WriteLine("CATALAN_TEST"); Console.WriteLine(" CATALAN computes Catalan numbers."); Console.WriteLine(""); Console.WriteLine(" N exact C(I) computed C(I)"); Console.WriteLine(""); int n_data = 0; for (;;) { Burkardt.Values.Catalan.catalan_values(ref n_data, ref n, ref c); if (n_data == 0) { break; } int[] c2 = new int[n + 1]; c2 = Catalan.catalan(n); Console.WriteLine(" " + n.ToString().PadLeft(4) + " " + c.ToString().PadLeft(8) + " " + c2[n].ToString().PadLeft(8) + ""); } }
private static void test005() //****************************************************************************80 // // Purpose: // // TEST005 tests CATALAN and CATALAN_VALUES. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 05 August 2013 // // Author: // // John Burkardt // { int c = 0; int n = 0; Console.WriteLine(""); Console.WriteLine("TEST005"); Console.WriteLine(" CATALAN computes Catalan numbers."); Console.WriteLine(" CATALAN_VALUES returns some exact values."); Console.WriteLine(""); Console.WriteLine(" N exact C(I) computed C(I)"); Console.WriteLine(""); int n_data = 0; for (;;) { Burkardt.Values.Catalan.catalan_values(ref n_data, ref n, ref c); if (n_data == 0) { break; } int[] c2 = Catalan.catalan(n); Console.WriteLine(" " + n.ToString().PadLeft(4) + " " + c.ToString().PadLeft(6) + " " + c2[n].ToString().PadLeft(6) + ""); } }
public static void catalan_values_test( ) //****************************************************************************80 // // Purpose: // // CATALAN_VALUES_TEST tests CATALAN_VALUES. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 02 March 2007 // // Author: // // John Burkardt // { int c = 0; int n = 0; Console.WriteLine(""); Console.WriteLine("CATALAN_VALUES_TEST:"); Console.WriteLine(" CATALAN_VALUES returns values of "); Console.WriteLine(" the Catalan numbers."); Console.WriteLine(""); Console.WriteLine(" N C(N)"); Console.WriteLine(""); int n_data = 0; for ( ; ;) { Catalan.catalan_values(ref n_data, ref n, ref c); if (n_data == 0) { break; } Console.WriteLine(" " + n.ToString().PadLeft(6) + " " + c.ToString().PadLeft(10) + ""); } }
public static void catalan_row_next_test() //****************************************************************************80 // // Purpose: // // CATALAN_ROW_NEXT_TEST tests CATALAN_ROW_NEXT. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 11 October 2006 // // Author: // // John Burkardt // { const int N_MAX = 10; int[] c = new int[N_MAX + 1]; int i; Console.WriteLine(""); Console.WriteLine("CATALAN_ROW_NEXT_TEST"); Console.WriteLine(" CATALAN_ROW_NEXT computes a row of the Catalan triangle."); Console.WriteLine(""); Console.WriteLine(" First, compute row 7:"); bool next = false; int n = 7; Catalan.catalan_row_next(next, n, ref c); string cout = n.ToString().PadLeft(4) + " "; for (i = 0; i <= n; i++) { cout += c[i].ToString().PadLeft(8) + " "; } Console.WriteLine(cout); Console.WriteLine(""); Console.WriteLine(" Now compute rows consecutively, one at a time:"); Console.WriteLine(""); next = false; for (n = 0; n <= N_MAX; n++) { Catalan.catalan_row_next(next, n, ref c); next = true; cout = n.ToString().PadLeft(4) + " "; for (i = 0; i <= n; i++) { cout += c[i].ToString().PadLeft(6) + " "; } Console.WriteLine(""); } }