Just going through my C++ book and came across an exercise about iterators and vectors and stuff.
It asked me to write a program (using iterators in a for loop) that would take ints into a vector and then reverse the vector before printing it.
i.e. if I enter 1 2 3 4 5 into the console window it would print out as 5 4 3 2 1 (with new lines instead of spaces).
The for loop I wrote went like this...
data is my vector storing the inputs.
i.e. up starts at the front and goes up. down starts at the last entry (NB not the off the end entry) and goes down. if up >= down then it ends.
This worked perfectly and fit everything into the for loop control. It seemed to work a treat.
However, the book came up with this...
It seems like their way is a lot more long winded and harder to read (for me anyway).
Which would you prefer?