It has to do with the justification of your text. The first time you print the table, you use left
to set the justification. You should use cout << right
before printing the second table.
Each stream has a set of format flags. At the start of the program, standard streams (for example, cout
) have their adjustfield
set to right
. That is why the first time you print your table, everything works: the first line of your table code correctly assumes right-justified text. Once you set the justification to left
on the second line, it remains that way until you change it. So you can actually remove the other left
s on the second line of your table code, because the first one is enough.
For the second table code to work correctly, you need to revert back to right justification. So right after the empty line between the two tables, you should insert cout << right;
.