2D Array n*n

hello

I have a project I have to end it in three days from now

This is the project:-

http://postimg.org/image/ahosql5mx/



I do not know how to make the user enters the values of the 2D array
I do not know how can I make the robot moves from the starting point to the ending point

and that is my code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include<iostream>
#include <cstdlib>
#include <ctime>
#include "node.h"
using namespace std;

int main ()
{
	int  x , y , w , z , s , e , o , k , l;
	cout<<"Please Enter The Value Of The Columns :  "  << endl;
	cin>>n;
	m=n*n;
	int Array[n][m] = {0};
	cout<<"What Is The Starting Point ??"<<endl;
	cin>> x;
	cin>> y;
	s=Array[x][y];
	cout<<"What Is The Ending Point ??"<<endl;
	cin>> w ;
	cin>> z ;
	e=Array[w][z];
	srand(time(0));
	o=(n*n)/4;
	for (int c = 0; c < m; ++c) // step through the rows in the array
    cout << Array[c][c] << endl;
	for (int i=0 ; i < o ; i++)
	{
		Array[k][l]= 1+(rand()%o) ;
	}	
	getchar();
	return 0;
}


i have no idea what to do now :(
Last edited on
please any one help me :(

im really lost and i dont no what to do
int x , y , w , z , s , e , o , k , l;

You have created tons of variables, except for the one you use first. You never create an integer variable called n, so ofc you can't use it

cin>>n;

Same with m

int Array[n][m] Also this is invalid in c++. If you want to create user-chosen-size arrays, you're gonna have to do it dynamically. int* Array = new int[n][m]

http://www.cplusplus.com/doc/tutorial/dynamic/

Also, in your project instruction it says an n*n chess field. Not n*(n*n) which is how you have it right now because m is n*n.

As a final tip, give your array a decent name.
Last edited on
Topic archived. No new replies allowed.