Not a good idea still unless is homework...there are any number of ways to do so; about as simple as any would be
preallocate, of course.
As "exercise for Student", with minor alterations the above will work silently if the length of the input vector is odd as well. HINT: start w/
instead and work form there...
Both, of course, presume the input vector is alternating odd-even rather than looking at what the values in the vector are and selecting by it.