473,769 Members | 2,515 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem writing in the trail of matrix of maze program

1 New Member
Hi
im an IT student.I have registered as a member of this site recently.I have a question about the solution of maze program. I want to write maze program in c++ .I want to solve the maze class includes two methods: 1)makeMaze & 2)runMaze.
I write the method of makeMaze in a way that fulls a n*n matrix.
one of my problem is about the writing the code of dynamic 2D array allocation .
an another is about the writing the method of runMaze in a way that finds the path for movment and then print this in a trail of matrix and as we know the "main" is necessary to write it.
I saw the maze program that you have written in the part of "c++ maze program"
but the code of that post dosent follow the path of movment in a trail of matrix.
here is the code:


#include<iostre am.h>
#include<conio. h>
#include<stdlib .h>

class maze {
int a[100][100];
public:
void makeMaze();
void runMaze(int row, int col);
};
//*************** *************** *************** ******
void maze :: makeMaze()
{
clrscr();
srand(time(0));
int maze[10][10]={0};
int i,j=0;
for( i=0;i<10;i++)
for(j=0;j<10;j+ +)
maze[i][j] =random(2);
for( i=0;i<10;i++){
for(j=0;j<10;j+ +)
cout<<maze[i][j]<<"\t";
cout<<endl<<end l;
}
}
//*************** *************** *************** ********
void maze :: runMaze(int row, int col)
{
// int col = 1;
// int row = 2;

if( (row>0 && row<10) && (col>0 && col<10)) {
if( a[row][col] == 'W' ) return;

if( a[row][col] == ' ') {
a[row][col]='*';

runMaze(row, col+1);
runMaze(row, col-1);
runMaze(row-1, col);
runMaze(row+1, col);
}
}
}
//*************** *************** *************** **********
int main()
{
clrscr();
maze m;
m.makeMaze();
m.runMaze(1, 2);
getch();
return 0;
}
Im in a hurry.
please help me to solve this qustion very soon.
thank you
Jun 4 '07 #1
1 3392
DeMan
1,806 Top Contributor
Hi Daneshjo,

Welcome to thescripts. As this question is c/c++ related, I will now move it to the appropriate forum. While you will still be able to find this question from the link here, any future posts can be made directly to the technical forums (which can be found from the links on the blue bar near the top of your screen).

I hope the c/c++ experts can help you with your enquiry!!
Jun 4 '07 #2

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

Similar topics

2
21422
by: Roger Douglass | last post by:
I've been working on this program for school and I just about got it before I had to turn it in. Here's my final code on it. I didn't finish it, but I think I'm pretty close. M is the starting point in the maze and W the finish. Using recursion the program is to leave a trail of asterisks (*) showing the solution. Well, I got stumped on this one. I found something similar to it online, but not quite what I was looking for.
2
3002
by: Syed Ghayas | last post by:
Hi, I've been having problem writing a cookie. Everything goes ok but when I supply the .Path property to "/" It just write the cookie when there is no cookie present, but when I try to update the cookie (or overwrite the cookie) it doesnt change it. My requirement to supply the path to "/" because ASP.NET reads it. If I write the cookie without supplying the path, the ASP.NET pages are unable to read the cookie.
3
1302
by: lsumnler | last post by:
I have started to work through Teach Yourself ASP.Net in 24 hours. The problem that I have noticed is - When I place a textbox Web Control on the screen and then try to change the "ID" in the property window it does not retain the change to the ID. Example (ID) = AutoText1 I change it to loanAmount and press enter it goes right back to AutoText1. The only way I can change it is by right clicking on the textbox control and selecting...
5
9280
by: vijay.db | last post by:
Hi Group, I'm running DB2 UDB Enterprise Edition V7.1 in AIX 4.3.3.0. And database backups goes to the TSM server. We have the following TSM Client API installed in the server: tivoli.tsm.client.api.aix43.32bit 5.1.6.0 C TSM Client - Application Programming Interface Now my backup getting terminated with the following message in the
19
4780
by: rmr531 | last post by:
First of all I am very new to c++ so please bear with me. I am trying to create a program that keeps an inventory of items. I am trying to use a struct to store a product name, purchase price, sell price, and a taxable flag (a Y/N char) and then write this all out to a file (preferably just a plain old text file) and then read it in later so that I can keep a running inventory. The problem that I am running into is when I write to the...
1
1962
by: dcatunlucky | last post by:
Ok, I have an assignment to write a program that multiplies two matrices. The matrices dimensions will be user defined as well as the numbers (floating point values) inside of them. The program must check to see if the two matrices are able to be multiplied. This is the code that I have so far: #include "stdafx.h" #include <iostream> using namespace std;
4
1306
by: Nangi | last post by:
Hi, I've got a problem with this code. I've got a double Matrix A and a vector b, initialized with DoubleMatr A = new double*; DoubleVect b = new double; where DoubleMatr and DoubleVect are defined as typedef double* DoubleVect;
6
3747
by: girishc13 | last post by:
i have written the below program for matrix mult using pointers and functions. the code is: #include<stdio.h> int M = 3,N = 2; main() { int mat1,mat2,i,j,res; void matmul(int *a,int *b,int *c); printf("\n enter the matrix elements row wise the size is %dx%d \n",M,N);
2
1408
by: Hala Civil | last post by:
good evening,well i'm kinda facing a problem while running my c++ program (run time error!!),the program contains a large number of if statements but all gathering around the same point,,,it's designed to assign values for factors z1f_a1 ,z2f_a1 ,z1r1_a1 , z2r2_a1, if certain conditions of H,A,K1,K2 are met... the code is attached as a txt file,plz i need help before 40 hours. thx :)
0
9579
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10036
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9987
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9855
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8863
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5444
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3952
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3558
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2812
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.