473,402 Members | 2,053 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,402 software developers and data experts.

Problem writing in the trail of matrix of maze program

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<iostream.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<<endl;
}
}
//************************************************** ***
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 3368
DeMan
1,806 1GB
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
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...
2
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...
3
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...
5
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: ...
19
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,...
1
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...
4
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...
6
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...
2
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...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
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...
0
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...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.