Spacing issue

Hello. I'm having some troubles with spacing. I would also like to add a list of numbers at the beginning of each row for easy navigation, but I have absolutely no idea how to do either of these things. Could you guys help me out? This is what my output looks like:

1
2
3
4
5
6
7
   A B C D E F G H I
7 2 3 |      |1 5 9
6     |3   2 |    8
8     |  1   |    2
  7   |6 5 4 |  2
    4 |2   7 |3
  5   |9 3 1 |  4
-----+-----+-----
5     |  7   |    3
4     |1   3 |    6
9 3 2 |      |7 1 4


And this is what I would like it to look like:

1
2
3
4
5
6
7
   A B C D E F G H I
1  7 2 3|     |1 5 9
2  6    |3   2|    8
3  8    |  1  |    2
  
4    7  |6 5 4|  2
5      4|2   7|3
6    5  |9 3 1|  4
   -----+-----+-----
7  5    |  7  |    3
8  4    |1   3|    6
9  9 3 2|     |7 1 4


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
{
   //Display Column Header
   cout << "   A B C D E F G H I" << endl;

   for (int row = 0; row < 9; row++)
   {
      for (int col = 0; col < 9; col++)
      {
         if (sudokuBoard[row][col] == 0)
            cout << " " << " ";
         else
         {
            cout << sudokuBoard[row][col] << " ";
         }

         //Don't print on last run (c = 8)
         //Print vertical line if we've printed 3 columns
         if (col != 8 && (col + 1) % 3 == 0)
            cout << "|";
      }
      //Don't print on last run (c = 8)
      //Print newline if we've printed 3 rows
      if (row != 8 && (row + 1) % 3 == 0)
         cout << "\n-----+-----+-----";
      cout << endl;
   }

   cout << "\n";

   getOption(sudokuBoard);
}
what i see is that, your code is fine... its just that you have put 3 spaces before letter A, at the line 3. just between line15 and 16, put something like this,
1
2
            if(!row)
                cout << " ";
Topic archived. No new replies allowed.