maze in an array

Here is the problem once i initialise the n x n area of maze in array ,i cannot correctly specific the exact location of the robot starting point to move


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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <iostream>
#include <conio.h>
#include <iomanip>

using namespace std;

int main()
{
    int n,column,row;
    char square[n][n];
    
    cout <<"Set the value of n x n squares area:"<<endl;
    cout <<"Enter the value for first n:";
    cin >> n;
    for(int x=0;x<n;x++)
    {
            for(int y=0;y<n;y++)
            {
            square[x][y]='#';
            }
            }
    for(int x=0;x<n;x++)
    {cout<<setw(7);
    for(int y=0;y<n;y++)
    {
    cout << square[x][y];
    }
    cout<<endl;
    }
    
    cout <<"Now specific the robot starting point to move:"<<endl;
    cout <<"Enter which column:(starting from 0)";
    do{
    cin >> column;
    if(column > (n-1))
    cout<<"The column size is more than the square areas,please enter again:";
    }while(column>(n-1));
    
    cout <<"Enter which row:(starting from 0)";
    do{
    cin >> row;
    if(row > (n-1))
    cout<<"The column size is more than the square areas,please enter again:";
    }while(row >(n-1));
    
    cout<<"The row is "<<row<<endl;
    cout<<"The column is "<<column<<endl;
    
    square[4][4]='*';
    for(int x=0;x<n;x++)
    {cout<<setw(7);
    for(int y=0;y<n;y++)
    {
    cout << square[x][y];
    }
    cout<<endl;
    }
    
    
    
            
            
            
    
    
    
    
    
    getch();
    return 0;
    
}



the final output did not correctly match the location of starting point of column and row.For example when i key in the value of 2 for both row and column,
the * symbol which use as a robot would emerge in several places.Why?
Please don't duplicate posts. I have already posted in your other post.
Topic archived. No new replies allowed.