# include # include # include # include "collatz_recursive.h" int main ( ); void test01 ( ); void timestamp ( ); /******************************************************************************/ int main ( ) /******************************************************************************/ /* Purpose: collatz_recursive_test() tests collatz_recursive(). Licensing: This code is distributed under the MIT license. Modified: 09 March 2012 Author: John Burkardt */ { timestamp ( ); printf ( "\n" ); printf ( "COLLATZ_RECURSIVE_TEST():\n" ); printf ( " C version\n" ); printf ( " Test COLLATZ_RECURSIVE().\n" ); test01 ( ); /* Terminate. */ printf ( "\n" ); printf ( "COLLATZ_RECURSIVE_TEST():\n" ); printf ( " Normal end of execution.\n" ); printf ( "\n" ); timestamp ( ); return 0; } /******************************************************************************/ void test01 ( ) /******************************************************************************/ /* Purpose: TEST01 tests COLLATZ_PATH; Licensing: This code is distributed under the MIT license. Modified: 09 March 2012 Author: John Burkardt */ { int n; int n_test[5] = { 7, 8, 9, 10, 600 }; int test; int test_num = 5; printf ( "\n" ); printf ( "TEST01\n" ); printf ( " COLLATZ_PATH prints the members of a Collatz path.\n" ); for ( test = 0; test < test_num; test++ ) { n = n_test[test]; printf ( "\n" ); printf ( " %d is the starting point.\n", n ); collatz_path ( n ); } return; } /******************************************************************************/ void timestamp ( ) /******************************************************************************/ /* Purpose: timestamp() prints the current YMDHMS date as a time stamp. Example: 31 May 2001 09:45:54 AM Licensing: This code is distributed under the MIT license. Modified: 24 September 2003 Author: John Burkardt */ { # define TIME_SIZE 40 static char time_buffer[TIME_SIZE]; const struct tm *tm; time_t now; now = time ( NULL ); tm = localtime ( &now ); strftime ( time_buffer, TIME_SIZE, "%d %B %Y %I:%M:%S %p", tm ); printf ( "%s\n", time_buffer ); return; # undef TIME_SIZE }

AltStyle によって変換されたページ (->オリジナル) /