I wrote a program to insert the numbers in C++ with CLion.
First, enter a set of positive integers and place them into the vector called pour. Then, take the negative numbers of these positive integers and then emplace them into the pour. However, when I tried to use the range-based for loop to insert the negative numbers into the pour, the last element always gave a random number without any reason. But once I don't use the range-based loop, the last element won't give me a random number.
#include <iostream>
#include <vector>
using namespace std;
int n , m ;
vector<int> pour ;
int main()
{
    for (int i=0 ; i<3 ; ++i)
    {
        cin >> m ;
        pour.emplace_back(m) ;
    }
    for (auto i : pour)
    {
        pour.emplace_back(-i) ;
    }
    for (auto i : pour)
    {
        cout << i << endl ;
    }
    return 0;
}
 
    