#include <iostream>#include <conio.h>#include <iomanip>#include <stdio.h>using namespace std;const int maxx = 100;int cities;int road;int TOUR[maxx];int Available[maxx];bool VALID_ROAD[maxx][maxx];bool VALID_CITY[maxx];int current_city, moving_city;void INITIAL(){ for ( int i = 0; i < cities; i++ ) for ( int j = 0; j < cities; j++ ) VALID_ROAD[i][j] = false; for ( int i = 0; i < cities; i++ ) VALID_CITY[i] = true;}void PRINT(){ for ( int i = 0; i < cities; i++ ) { cout << TOUR[i] << " -> " ; } cout << endl;}void JOURNEY ( int i ){ for ( int j = 1; j < cities; j++ ) { if ( VALID_CITY[i] == true && VALID_ROAD[i][j] == true ) { TOUR[i] = j; if ( i == moving_city ) { PRINT(); getch(); } else { VALID_CITY[i] = false; JOURNEY ( i + 1 ); VALID_CITY[i] = true; } } }}int main(){ int first_city, second_city; cout << "Enter the number of city: "; cin >> cities; cout << "Enter the number of valid-road: "; cin >> road; INITIAL(); cout << "---------------ENDL-------------" << endl; cout << "Now, what city you currently live: "; cin >> current_city; cout << "What city would you like to move to: "; cin >> moving_city; cout << "---------------INFORMATION MAP----------------" << endl; int times = 0; do { cout << "Enter the information of the road, first city:"; cin >> first_city; cout << endl; cout << " and second city: "; cin >> second_city; VALID_ROAD[first_city][second_city] = true; times++; Available[times] = second_city; } while ( times < road ); int check_times = 0; for ( int i = 0; i < road; i++ ) { if ( Available[i] == moving_city ) check_times++; } if ( check_times == 0 ) { cout << "No way for you to move: "; } else { TOUR[0] = current_city; JOURNEY ( current_city + 1 ); } return 0;}