Alternate TAB/SPACE Printing for Vector
Dear all,
I have vectors which content is multiply of 4.
For example this (surely the actual vector size is much
larger than this).
|
[40,10,30,-1, 20,3,50,40, 30,3,3,5]
|
What I want to do is to print the vector alternately 4 by 4.
Each block of four is separated by a TAB, else by space, e.g:
|
40 10 30 -1<TAB>20 3 50 40<TAB>30 3 3 5
|
Is there a way to achieve that?
You can:
std::cout << vectorElement << "/t" << vectorElementTwo << std::endl;
1 2 3 4 5
|
for (int i = 0; i < vector.size(); ++i) {
cout << vector[i] << " ";
if ( (i%4) == 0)
cout << "\t";
}
|
Topic archived. No new replies allowed.