Answer:
The program is as follows:
#include<iostream>
#include<vector>
using namespace std;
int main() {
vector<int> myInputs;
int num;
cin>>num;
while(num !=0){
myInputs.push_back(num);
cin>>num;}
for (int i = 0; i < myInputs.size(); i++){
if(myInputs[myInputs.size()-1]!=myInputs[i]){
cout << myInputs[i] << " "; }
}
return 0;
}
Explanation:
Declare integer vector of elements
vector<int> myInputs;
Declare num for integer inputs
int num;
Get input for num
cin>>num;
This loop is repeated until input is 0
while(num !=0){
Push the input to the vector
myInputs.push_back(num);
Get another input
cin>>num;}
Iterate through the vector elements
for (int i = 0; i < myInputs.size(); i++){
For vector elements not equal to the last element
if(myInputs[myInputs.size()-1]!=myInputs[i]){
The element is printed
cout << myInputs[i] << " "; }
}