The mistake was to try to code it without planning.
Get yourself a piece of graph paper and a pencil (or a fixed-width text editor) and
draw the final result. (Congratulations, you have already done that!)
Next, look at it
line by line and figure out how to produce each line.
The first line, for example, is:
1 2 3 4 5
|
// first line
cout << '|';
for (int n = 0; n < CELL_WIDTH * 8; n++)
cout << '-';
cout << "|\n";
|
Conveniently, that is also the
last line.
There are several hints in that snippet about drawing each successive line. I would personally use a modulo/remainder trick to decide whether to draw spaces or symbols in a given cell, but you could just make a loop over four groups of two vertical cells each...
You have to count and think about the loops to produce a cell, a line, and a pair of lines.
Forget the black and white variables. They are adding complexity that is messing you up.
[edit] Once you can produce the whole thing, then look at the problem again and see if you can reduce it using some loops.
Good luck!