Final answer:
To solve this problem, you need to read integers from input and store them in a vector until 0 is encountered. Then, output the values in the vector that are not equal to the last value in the vector.
Step-by-step explanation:
To solve this problem, you will need to use a loop to repeatedly read integers from the input and store them in a vector until a 0 is encountered. However, you should not store the 0 itself in the vector. Once the loop ends, you can iterate over the vector and output each value that is not equal to the last value in the vector.
C++ code:
#include <iostream>
#include <vector>
using namespace std;
int main() {
int num;
vector<int> numbers;
cin >> num;
while (num != 0) {
numbers.push_back(num);
cin >> num;
}
int lastValue = numbers.back();
for (int i = 0; i < numbers.size(); i++) {
if (numbers[i] != lastValue) {
cout << numbers[i] << endl;
}
}
return 0;
}