# include # include # include # include # include using namespace std; # include "combination_lock.hpp" int main ( ); //****************************************************************************80 int main ( ) //****************************************************************************80 // // Purpose: // // MAIN is the main program for COMBINATION_LOCK_TEST. // // Discussion: // // COMBINATION_LOCK_TEST tests the COMBINATION_LOCK library. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 13 May 2012 // // Author: // // John Burkardt // { int c[4] = { 1, 2, 3, 4 }; int m = 4; int n = 5; int step; timestamp ( ); cout << "\n"; cout << "COMBINATION_LOCK_TEST\n"; cout << " C++ version\n"; cout << " COMBINATION_LOCK tries to determine the combiantion of a lock.\n"; cout << " A combination lock consists of M dials,\n"; cout << " each having N symbols.\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"; i4vec_print ( m, c, " The \"secret\" combination:" ); step = combination_lock ( m, n, 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 << "COMBINATION_LOCK_TEST\n"; cout << " Normal end of execution.\n"; cout << "\n"; timestamp ( ); return 0; }