# include # include # include # # include "football_scores.h" # int main ( ); void timestamp ( ); /******************************************************************************/ int main ( ) /******************************************************************************/ /* 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 ( ); printf ( "\n" ); printf ( "football_scores_test()\n" ); printf ( " C version\n" ); printf ( " football_scores() computes the number of ways\n" ); printf ( " of achieving a particular score in football.\n" ); printf ( "\n" ); printf ( " We assume scoring options are:\n" ); printf ( "\n" ); printf ( " +1 for a one point safety (returned conversion\n" ); printf ( " after the other team scores a touchdown.\n" ); printf ( " +2 for a safety;\n" ); printf ( " +3 for a field goal;\n" ); printf ( " +6 for a touchdown with no followup;\n" ); printf ( " +7 for a touchdown with a point bonus;\n" ); printf ( " +8 for a touchdown with two point conversion;\n" ); printf ( "\n" ); printf ( " Score Ways\n" ); printf ( "\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++ ) { printf ( " %6d %25lld\n", i, s[i] ); } free ( s ); printf ( "\n" ); printf ( "football_scores_test()\n" ); printf ( " Normal end of execution.\n" ); printf ( "\n" ); timestamp ( ); return 0; } /******************************************************************************/ void timestamp ( ) /******************************************************************************/ /* Purpose: timestamp() prints the current YMDHMS date as a time stamp. Example: 17 June 2014 09:45:54 AM Licensing: This code is distributed under the MIT license. Modified: 01 May 2021 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 }