473,385 Members | 1,338 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

kindly help me to write program in c

The problem is like this:-


A maze is a rectangular area, with m rows and n columns, with an entrance and an exit. The interior of the maze contains obstacles. The entrance is at the upper-left corner, and exit is at the lower-right corner. A rat in a maze problem is to find a path from the entrance to exit of a maze. A path is basically a sequence of positions, none of which is blocked, and such that each (east,west south,north) neighbour of the preceding position. Write a program to find such path, if exits, otherwise output the message "No solution for this maze"
Sep 5 '06 #1
2 3819
D_C
293 100+
A recursive solution is the way to do it. Suppose you have a data structure maze, which contains the current (x,y) position of the rat, and also an mxn matrix with obstacles and the rat's "history" marked (which locations it has visited). Your algorithm should be something like:
Expand|Select|Wrap|Line Numbers
  1. if(rat is in the exit position)
  2. {
  3.   do what is necessary;
  4.   return;
  5. }
  6. if(rat has not been left) // go left
  7. {
  8.   move left;
  9.   solve maze;
  10.   move right; // undo going left
  11. }
  12. // similarly for go down, go right, and go up also
Sep 5 '06 #2
The problem is like this:-


A maze is a rectangular area, with m rows and n columns, with an entrance and an exit. The interior of the maze contains obstacles. The entrance is at the upper-left corner, and exit is at the lower-right corner. A rat in a maze problem is to find a path from the entrance to exit of a maze. A path is basically a sequence of positions, none of which is blocked, and such that each (east,west south,north) neighbour of the preceding position. Write a program to find such path, if exits, otherwise output the message "No solution for this maze"
CODE:
1.start at entrance.
2.at this point u may have 3 ways to move forward,select any one of that ,say(i,j)th cell.
3.mark it as visited.
4.simultaneously build a tree using the marked cells along with entrance &exit.
5.so at this point u may have again 3 ways ,choose any one
if this is an obstacle,mark as deadend &backtrace
else repeat steps 2,3,4,5until u reach exit.
Apr 12 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Naren | last post by:
Hello All, I dont get errors but I get warnings though the code runs fine. Could anyone help me removing these warnings c:\program files\microsoft visual studio\vc98\include\vector(48) : warning...
18
by: jacob navia | last post by:
In C, we have read-only memory (const), read/write memory (normal data), and write only memory. Let's look at the third one in more detail. Write only memory is a piece of RAM that can only...
5
by: roopeman | last post by:
i wrote the below code , just want got local machine application Eventlog 's message , and write to MDB.but it 's can not write the message to Mdb, somebody can check it for me? thanks! ...
1
by: Chris | last post by:
Hi, I am working on a small which involves a touchscreen and I need to create a on-screen keyboard. I need some assistance with a few questions 1. For the the buttons, do I user their text as...
11
by: Siddhu | last post by:
Hai, i am student & i have struck up with the following program's output. Kindly help me to reason out why the output goes as which is given below. THE PROGRAM goes as; #include<iostream.h>...
2
by: nikki123 | last post by:
Hi all, can anyone help me for the following C++ program. i want to write a program which read a file of C language and Print Lines of Codes and print signature of all function (including main) in...
1
by: Sachin Garg | last post by:
I have a program which opens a fstream in binary input+output mode, creating the file if it doesn't exists. But writing doesn't works after reading, it must be something obvious that I am not aware...
2
by: vijayrvs | last post by:
SearchCrawler.java The program search crawler used to search the files from the website. From the following program i got 7 compiler error. can any body clarify it and provide me solution. ...
3
sreekandank
by: sreekandank | last post by:
I want to implement POP3 program in java....I have written the code like... import javax.mail.*; import javax.mail.internet.*; import java.util.*; import java.io.*; public class POP3Client {...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.