problem with formatting my for loop

Hi, I am trying to make a program that guesses a random number and then the user has to guess that random number by entering a guess for the row and a guess for the column. I am making a grid to display the amount of rows and columns and should have an "X" where the user's guess is and hint characters (<, >, ^, v) for giving hints as to which way the point really is.

Here's what my grid should look like if the user enters 2 for row and 3 for column and the row number secret point is higher and the column number secret point is smaller:
. . < . . .
v v X v v v
. . < . . .
. . < . . .

But mine is all messed up and looks more like this:
. . . > . . .
. v . vX . v > . v . v .

. . . > . . .

Can someone please help me fix it? :(




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
73
74
75
y = (rand() % MAX_ROWS) + 1;
	x = (rand() % MAX_COLUMNS) + 1;

for (int i = 1; i <= MAX_ROWS; i++)
					{
						for (int j = 1; j <= MAX_COLUMNS; j++)
						{

							if((i == rGuess) && (j == cGuess))
							{
								cout << 'X';
							}


							if(rGuess > y)
							{
							cout << ".";
							

								if(i == rGuess)
								{

									cout << "^";

								}
	 
						 
							}

							else if(rGuess < y)
							{
								cout << ".";
								
								if(i == rGuess)
								{

									cout << "v";

								}
							}
							else if(rGuess == y)
							{
								cout << ".";
							}



							if(cGuess > x)
							{
								if(j == cGuess)
								{
									
									cout << "<";

								}
							}

							else if(cGuess < x)
							{
								
								if(j == cGuess)
								{
									
									cout << ">";

								}
							}

							else if(cGuess == x)
							{
								cout << ".";
							}
						}
						cout << "\n";
					}
Nobody can help me?? :(
Topic archived. No new replies allowed.