Home > database >  Anyone who can help me have a look at my code where is wrong, is the tenth blue cup maze problem, I
Anyone who can help me have a look at my code where is wrong, is the tenth blue cup maze problem, I

Time:09-22

Title:
Labyrinth test E:
Subject: total score 15 points,
[problem description]
The figure below shows a labyrinth floor plan, which is marked as 1 for obstacles, to be marked as 0
Commonly,
010000
000100
001001
110000
Maze of entry to the upper left corner, exports to the lower right corner, in the maze, but only from one location to be in this
On it, down, left, right is one of the four directions,
For the maze, starting from the entrance, can press DRRURRDDDR order through the maze,
Step 10, where D, U, L, R, respectively is down, up, left, right,
For the more complicated maze below (line 30 50 columns), please find a way through the maze,
To use the steps of the least, under the premise of steps in the least, please find the dictionary sequence youngest as an answer,
Please note in the dictionary sequence D<. LShall examine the content of the copy is consistent with the document, in a file directory test maze. TXT,
Content and the text below the same)
01010101001011001001010110010110100100001000101010
00001000100000101010010000100000001001100110100101
01111011010010001000001101001011100011000000010000
01000000001010100011010000101000001010101011001011
00011111000000101000010010100010100000101100000000
11001000110101000010101100011010011010101011110111
00011011010101001001001010000001000101001110000000
Try E: maze 7

[the answers submitted]
This is a result of the fill in the blanks, you only need to calculate the result can be submitted after, the result of the subject as a
A string that contains four kinds of D, L, U, R
# include
using namespace std;
Int v [101] [101]={0};
Char map [101] [101].
Int que [100000] [4].//que [x] [0] and que [x] [1] respectively horizontal ordinate, que [2] and [x] que [x] [3] are moved in the direction and precursor
Int d [4], [3]={0,1,1,0, 1, 2, 1,0,3,1,0,4};//the up and down or so change, represented by 1 - D, 2 - L, 3 R, 4 - U

Void dayin (int x) {
If (que [x] [3]!=0)
{

Dayin (que [x] [3]).
cout<& lt; Que [x] [2] <" ";

}
cout<" A "& lt; <" ";

}

Int main ()
F={FILE * fopen (" maze. TXT ", "r");
for(int i=1; i<=30; I++) fscanf (f "% s", & amp; The map [I]); Int head=0;
Int tail=1;
Que [1] [0]=1;//will be the starting point team que [1] [1]=1;
Que [1] [2]=0; Que [1] [3]=0; While (head{head++; Int x=que [head] [0]; Int=y que [head] [1]; for(int i=0; i<4. I++) {int x1=x + d [I] [0]; Int y1=y + d [I] [1]; If (1 & lt;=x1 & amp; & The x1 & lt; 30 & amp; & 1<=y1 & amp; & Y1 & lt; 50 & amp; & V [x1] [y1]==0 & amp; & The map [x1] [y1]=='0') {que [tail] [0]=x1; Que [tail] [1]=y1; Que [tail] [2]=d [I] [2];//records go in the direction of the que [tail] [3]=head;//record precursor v [x1] [y1]=1; Tail++; } the if (x1==30 & amp; & Y1==50) {dayin (head);//back function}}}} is the image data read file

CodePudding user response:

Code is a bit messy, I resend one