3) Write a program that reads a 21 by 21 array of characters from a text file. It
represents a maze.
• Each position can contain either an X or a blank. The borders of the maze are covered by ‘X’ except start and exit points.

• Read text file as a character array and find start and finish points on the array borders (it doesn't matter which one is start or finish point)

• Find a path from start point to the finish point. Only horizontal and vertical moves are allowed.(right, left, up and down).

• If no path exists, write a message indicating there is no path. If there is a path to the exit location, mark the path with “O” and display the solution maze on the screen.
• Moves can be made only to locations that contain a blank. If an X is encountered, that path is blocked and another must be chosen.

Use recursion. The test mazes are given and example maze is at the second pages:

"That's my 3rd homework about C language and i tried to set 4 for algorithms for this.. but none of algorithms didnt work or process clearly..are there anybody can help me for set up an algorithm?" Please send the algorithm to my e-mail: [email removed]

Recommended Answers

All 4 Replies

Post your algorithm, code for try, and attach the test file (advanced view, manage attachments) error log and explanation of what you did to debug the program.

There is plenty of posts on subject even here in DaniWeb, algorith for recursive solver s very well explained in this post in Python forum for example: http://www.daniweb.com/software-development/python/threads/280814/1211178#post1211178

The most rudimentary shell is structured as the following loop:
1. Print out a prompt (e.g., "aos_spring11_shell$ ");
2. Read a line from the user;
3. Parse the line into the program name and an array of parameters;
4. Use the fork() system call to spawn a new child process;
o The child process then uses the exec() system call (or one of its variants) to launch the specified program;
o The parent process (the shell) uses the wait() system call (or one of its variants) to wait for the child to terminate;
5. Once the child (the launched program) finishes, the shell repeats the loop by jumping to 1.

plz help me must today and do all solution in C file

Happy coding! Post your code in case of any specific problem. Take one step (function) at time and test. Do not do another function until you are sure previous ones are correct (by test function). Use first hard coded input (even ready in binary form in program, not text form). Later you can add file input routine to get information from file/stdin and transform it to needed internal form.

Do the path finding first with hard code enter and exit points. After it works you can add finding the points, even it is simple scan routine, but concentrate to main points first) Use the description in link I posted before for how the recursion works and verify with the hard coded labyrinth (maybe already through function read_labyrinth so you can just update that function later to take information from file instead of hard coded values).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.