// SIMPLE CONNECTION CHECKING PROGRAM for MAZEs or IMAGES // program tested using g++ version 2.7.2 #include #include #include #define MAXROW 200 // max size of image is 200 x 200 #define MAXCOL 200 // Global image and object data used by all procedures String imagetitle; int numberofrows, numberofcolumns, connectivity; char image[MAXROW][MAXCOL]; void input_image () { fstream Infile; String filename; int row, col; char newlinechar; cout << "Please give name of file containing the input image: " << endl; cin >> filename; Infile.open ( filename, ios::in ); Infile >> imagetitle; cout << "Image title is : " << imagetitle << endl; Infile >> numberofrows; Infile >> numberofcolumns; cout << "and the image size is " << numberofrows << " x " << numberofcolumns << endl; for(row=0; row> start_r >> start_c >> goal_r >> goal_c; cout << " What connectivity? ( 4 or 8 ) - " << endl; cin >> connectivity; if ( (image[start_r][start_c] != ' ') | (image[goal_r][goal_c] != ' ') ) cout << "No connecting blank path since endpoints not both blank" << endl; else { // pour ink from start and see if it colors goal propagate_color(start_r, start_c, '+'); if ( image[goal_r][goal_c] != '+' ) cout << "No connecting blank path found." << endl; else cout << "Connecting path found." << endl; } output_image(); }