# include # include # include # include # include using namespace std; # include "bicycle_lock.hpp" int main ( ); //****************************************************************************80 int main ( ) //****************************************************************************80 // // Purpose: // // MAIN is the main program for BICYCLE_LOCK_TEST. // // Discussion: // // bICYCLE_LOCK_TEST tests the BICYCLE_LOCK library. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 14 August 2017 // // Author: // // John Burkardt // { int c; int m = 3; int n = 10; int seed; int step; timestamp ( ); cout << "\n"; cout << "BICYCLE_LOCK_TEST\n"; cout << " C++ version\n"; cout << " BICYCLE_LOCK seeks to determine the combination of a bicycle lock.\n"; cout << " A bicycle combination lock consists of 3 dials,\n"; cout << " each having 10 symbols, 0 through 9.\n"; cout << " We seek to determine the combination C.\n"; // // Report on the problem data. // cout << "\n"; cout << " The number of dials is M = " << m << "\n"; cout << " The number of symbols is N = " << n << "\n"; cout << " The number of possible combinations is M^N = " << i4_power ( n, m ) << "\n"; seed = get_seed ( ); c = i4_uniform_ab ( 0, 999, seed ); cout << " The \"secret\" combination is " << c << "\n"; step = bicycle_lock ( c ); if ( step == -1 ) { cout << "\n"; cout << " The combination was not found!\n"; } else { cout << "\n"; cout << " The combination was found on step " << step << "\n"; } // // Terminate. // cout << "\n"; cout << "BICYCLE_LOCK_TEST\n"; cout << " Normal end of execution.\n"; cout << "\n"; timestamp ( ); return 0; }