My goal is to have 3 columns of integers aligned like so:
3 109 136 223
4 95 237 230
5 200 76 153
With my code, this is the output I'm getting though:
I use a for loop to iterate through a vector and print the numbers.
Here is my for-loop which prints these numbers:
for (int i = 0; i < v.size(); i++)
{
cout << (i + 1);
cout.setf(ios::left);
cout.width(6);
cout << " " << v[i].firstColumn;
cout.width(8);
cout << " " << v[i].secondColumn;
cout.unsetf(ios::left);
cout << endl;
}
How can I make it so all of integers line up nicely? It seems as though the higher digit numbers are offsetting the columns (IE going from 9 to 10). Is there a way to fix this?