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
#include<iostream>
#include <cstdlib>
#include <ctime>
#include "node.h"
usingnamespace 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;
}
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]