迷宫问题#include<iostream> #include<vector> using namespace std; char **b; int m,n; struct mpoint { int x; int y; int up; int down; int left; int right; }; void mhouse() { int i,j; cout<<" 请依次输入表示迷宫中的通路和障碍的 0和 1"<<endl; for(i=1;i<=m;i++) for(j=1;j<=n;j++) cin>>b[i][j]; cout<<" 迷宫为: "<<endl; for(i=1;i<=m;i++) for(j=1;j<=n;j++) { cout<<b[i][j]; if(j==n) cout<<endl; }} void movepath() { vector<mpoint> path; mpoint start; //cout<<().x; if (b[1][1]!='0') { cout<<" 没有入口! "<<endl; } else if(b[m][n]!='0') { cout<<" 没有出口! "<<endl; } else { ==1; ==1; ==0; //=3; (start); while(true) { if(().x==m&&().y==n||()) break; else if (().right==0) { ().right=1; if(b[().x][().y+1]=='0') { mpoint rpoint; //rpoint=new mpoint; =().x; =().y+1; =1; ===0; (rpoint); //continue; } if(().left==1&& ().down==1&& ().up==1&&().right==1) (); } else if(().down==0) { ().down=1; if(b[().x+1][().y]=='0') { mpoint dpoint; //dpoint=new mpoint; =().x+1; =().y; =1; ===0; (dpoint); //continue; } if(().left==1&&().down==1&& ().up==1&&().right==1) (); } else if(().left==0) { ().left=1; if(b[().x][().y-1]=='0') { mpoint lpoint; //lpoint= new mpoint; =().x; =().y-1; =1; ===0; (lpoint); // continue; } if(().left==1&& ().down==1&& ().up==1&&().right==1) (); } else if(().up==0) { ().up=1; if(b[().x-1][().y]=='0') { mpoint upoint; // upoint=new mpoint; upoint.
迷宫问题 来自淘豆网www.taodocs.com转载请标明出处.