All pastes #560568 Raw Edit

Mine

public cpp v1 · immutable
·published 2007-06-12 03:58 UTC
rendered paste body
/* Xet so do gòm n nút giao thông danh sô tù 1 -> n và m doan duong nói chúng, môi doan duong nói 2 nút   giao thông s và d. Hãy nhap du lieu vè mang luoi giao thông dó, nhap só hieu 2 nút giao thông s và d.   Hay in ra tat ca các cách di tù s tói d và môi cách di không dc qua nút giao thông nào quá 1 làn.*/ #include <iostream>#include <conio.h>#include <iomanip>#include <stdio.h>using namespace std;const int maxx = 100;int cities;int road;int TOUR[maxx], TEMP_TOUR[maxx];bool VALID_ROAD[maxx][maxx];bool VALID_CITY[maxx];int Available[maxx];int current_city, moving_city;/*Khoi tao so dò giao thong */void INITIAL(){        for ( int i = 0; i < cities; i++ )                TEMP_TOUR[i] = i + 1;                for ( int i = 0; i < cities; i++ )                for ( int j = 0; j < cities; j++ )                        VALID_ROAD[i][j] = false;                        for ( int i = 1; i <= cities; i++ )                VALID_CITY[i] = true;        }void PRINT( int Z ){        for ( int i = 0; i < Z ; i++ )        {                cout << TOUR[i] << " -> " ;        }        cout << "\n\n";}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 ( TOUR[i] == moving_city ) /*Khi da toi dc TP càn tói, in ra ket qua hành trình */                        {                                PRINT(i+1); getch();                        }                        /*Neu chua toi goi de qui di tiep */                        else                        {                                VALID_ROAD[i][j] = false;                                VALID_CITY[i] = false;                                JOURNEY ( i + 1 );                                VALID_ROAD[i][j] = true;                                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 are you living in : ";      cin >> current_city;          cout << "What city would you like to move to :  -> ";  cin >> moving_city;                        cout << "-----------INFORMATION MAP-------------" << endl;        cout << "-----*-----[-------------]-----*-------" << endl;        cout << "-----*------[-----------]------*-------" << endl;        cout << "-----*-------[---------]-------*-------" << endl;        cout << "-----*--------[-------]--------*-------" << endl;        cout << "-----*---------[-----]---------*-------" << endl;        cout << "\n\n";                       /*Nhâp thong tin cho nhung duogn có hieu luc, TP nào có the tói TP nào */        int times = 0;        if ( current_city < moving_city )        {                               do                {                        cout << " THE " << times + 1 << "  ROAD" << endl;                        cout << "First city : [";  cin  >> first_city;  cout << " --->>> ";                        cout << "Second city: [";  cin  >> second_city;                                              VALID_ROAD[first_city][second_city] = true;                        times++;                        Available[times] = second_city;                } while ( times < road );                int check_times_I = 0;                for ( int i = 0; i <= road; i++ )                {                        if ( Available[i] == moving_city  ) check_times_I++;                 }                               if ( check_times_I == 0 )                        {                                cout << "No way for you get there !";                        }                        else                        {                                                                        TOUR[0] = current_city;                                        JOURNEY ( 1 );                        }        }          else         {                do                {                        cout << " THE " << times + 1 << "  ROAD" << endl;                        cout << "First city : [";  cin  >> first_city;  cout << " --->>> ";                        cout << "Second city: [";  cin  >> second_city;                        VALID_ROAD[first_city][second_city] = true;                        VALID_ROAD[second_city][first_city] = true;                        times++;                        Available[times] = first_city;                } while ( times < road );                int check_times_II = 0;                for ( int i = 0; i <= road; i++ )                {                        if ( Available[i] == moving_city  ) check_times_II++;                 }                               if ( check_times_II == 0 )                        {                                cout << "No way for you get there !";                        }                        else                        {                                TOUR[0] = current_city;                                JOURNEY ( 1 );                        }                              }               return 0;}