# include # include # include # include # include # using namespace std; # # include "football_scores.hpp" # int main ( ); void timestamp ( ); //****************************************************************************80 int main ( ) //****************************************************************************80 // // Purpose: // // football_scores_test() tests football_scores(). // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 21 September 2022 // // Author: // // John Burkardt // { int i; int n; long long int *s; timestamp ( ); cout << "\n"; cout << "football_scores_test()\n"; cout << " C++ version\n"; cout << " football_scores() computes the number of ways\n"; cout << " of achieving a particular score in football.\n"; cout << "\n"; cout << " We assume scoring options are:\n"; cout << "\n"; cout << " +1 for a one point safety (returned conversion\n"; cout << " after the other team scores a touchdown.\n"; cout << " +2 for a safety;\n"; cout << " +3 for a field goal;\n"; cout << " +6 for a touchdown with no followup;\n"; cout << " +7 for a touchdown with a point bonus;\n"; cout << " +8 for a touchdown with two point conversion;\n"; cout << "\n"; cout << " Score Ways\n"; cout << "\n"; // // You get a score of N points by // N-1 + a 1 point safety, // N-2 + a safety, or // N-3 + a field goal, or // N-6 + a touchdown with no followup // N-7 + a touchdown with a point bonus, or // N-8 + a touchdown with two point conversion. // n = 50; s = football_scores ( n ); for ( i = 0; i <= n; i++ ) { cout << " " << setw(6) << i << " " << setw(25) << s[i] << "\n"; } delete [] s; cout << "\n"; cout << "football_scores_test()\n"; cout << " Normal end of execution.\n"; cout << "\n"; timestamp ( ); return 0; } //****************************************************************************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 MIT license. // // Modified: // // 19 March 2018 // // Author: // // John Burkardt // { # define TIME_SIZE 40 static char time_buffer[TIME_SIZE]; const struct std::tm *tm_ptr; std::time_t now; now = std::time ( NULL ); tm_ptr = std::localtime ( &now ); std::strftime ( time_buffer, TIME_SIZE, "%d %B %Y %I:%M:%S %p", tm_ptr ); std::cout << time_buffer << "\n"; return; # undef TIME_SIZE }