Sep 23, 2016 at 1:44pm
No idea if you can somehow do it with cout in an easy way but you could use printf().
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
//ripped of from http://www.cplusplus.com/reference/cstdio/printf/
#include <stdio.h>
int main()
{
printf ("foo: %5d \n", 1);
printf ("foo: %5d \n", 12);
printf ("foo: %5d \n", 123);
printf ("foo: %5d \n", 1234);
printf ("foo: %5d bar: %7d", 1234, 5678);
return 0;
}
|
With the number after the % you can determine the width of the space where your numbers are inserted.
Last edited on Sep 23, 2016 at 1:45pm
Sep 23, 2016 at 1:50pm
@Arquon
Use the iomanip library or use the stdio.h library (from C language) and use printf() function.
Last edited on Sep 23, 2016 at 1:51pm
Sep 23, 2016 at 1:52pm
Last edited on Sep 23, 2016 at 1:53pm
Sep 23, 2016 at 4:44pm
line 10: The first field you're outputting is x. You have no setw() for x, so x defaults to the number of columns needed.
Sep 23, 2016 at 5:25pm
It worked, thank you ! It looks so beautiful to my eye right now.