c++ vector reverse algorithm
<p>I am trying to make a simple program which basically reverse the sequence of the vector. In other words after the program is ran, <code>x[0]</code> should be equal to <code>5</code>. The output which I am currently getting is <code>5234</code>. The <code>1</code> goes missing somewhere. I did include the <code>&lt;vector&gt;</code> header. Thanks in advance.</p>

<pre><code>int main()
{
    vector&lt;int&gt; x(5);
    x[0] = 1;
    x[1] = 2;
    x[2] = 3;
    x[3] = 4;
    x[4] = 5;
    for(int z = 0; z &lt; x.size()-1; z++)
    {
        int temp = x[x.size() - (1+z)];
        x[x.size() - (1+z)] = x[z];
        x[z] = temp;
    }
    for(int s = 0; s &lt; x.size() - 1; s++)
    {
        cout &lt;&lt; x[s] &lt;&lt; endl;
    }
    return 0;
}
</code></pre>
