All pastes #565967 Raw Edit

Mine

public cpp v1 · immutable
·published 2007-06-14 07:47 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 TOUR[maxx], TEMP[maxx];bool VALID_ROAD[maxx][maxx];bool VALID_CITY[maxx];int EXIST[maxx];int cities;int road;int current_city, moving_city;/*Khoi tao so dò giao thong */void INITIAL(){        for ( int i = 1; i <= cities; i++ )                for ( int j = 1; 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[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); getch();                        }                        /*Neu chua toi goi de qui di tiep */                        else                        {                                VALID_CITY[j] = false;                                                                JOURNEY ( i + 1 );                                                                VALID_CITY[j] = true;                            }                }        }}int main(){               int first_city, second_city;                   cout << "Enter the number of CITY: ";  cin >> cities;        cout << " ---> and VALID ROAD:  ";     cin >> road;                INITIAL();/*khoi tao các giá tri cua TP và duong di */                cout << endl;        cout << "---------------ENDL-------------" << endl;        cout << endl;                cout << "YOUR START :  ";                 cin >> current_city;          cout << " ------>  YOUR DESTINATION : ";  cin >> moving_city;                 cout << "\n\n";        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;                     do                {                        cout << " THE " << times + 1 << "  ROAD" << endl;                        cout << " THE FIRST CITY : [";        cin  >> first_city;                          cout << " --->>> ";                        cout << " .>.>THE SECOND CITY :  [";  cin  >> second_city;                                              VALID_ROAD[first_city][second_city] = true;                                                EXIST[times] = second_city; /*Luu thong tin dích dén */                        times++;                } while ( times < road );                                /*Kiem tra xem có duong di toi TP dích hay khong */                                bool check = false;                for ( int i = 0; i <= road; i++ )                {                        if ( EXIST[i] == moving_city ) check = true;                 }                               if ( check == false )                        {                                cout << "No way for you get there !";                        }                        else                        {                                TOUR[0] = current_city;                                VALID_CITY[current_city] = false;                                JOURNEY ( 1 );                        }        getch();        return 0;}