# include # include # include # include using namespace std; # include "collatz_recursive.hpp" //****************************************************************************80 void collatz_path ( int n ) //****************************************************************************80 // // Purpose: // // COLLATZ_PATH prints the members of a Collatz sequence. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 09 March 2012 // // Author: // // John Burkardt // // Parameters: // // Input, int N, the current path member. // { cout << " " << n << "\n"; if ( n == 1 ) { } else if ( n % 2 == 0 ) { collatz_path ( n / 2 ); } else { collatz_path ( 3 * n + 1 ); } return; } //****************************************************************************80 void timestamp ( ) //****************************************************************************80 // // 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 GNU LGPL license. // // Modified: // // 08 July 2009 // // Author: // // John Burkardt // // Parameters: // // None // { # define TIME_SIZE 40 static char time_buffer[TIME_SIZE]; const struct std::tm *tm_ptr; size_t len; std::time_t now; now = std::time ( NULL ); tm_ptr = std::localtime ( &now ); len = std::strftime ( time_buffer, TIME_SIZE, "%d %B %Y %I:%M:%S %p", tm_ptr ); std::cout << time_buffer << "\n"; return; # undef TIME_SIZE }