Write a program that inputs ten integer values from the keyboard. Each value should be pushed onto a
vector. After inputting the values, remove from the vector any repetition of a value. Finally output the list of
values that remain.
this is my homework but I dont understand exactly question can anybody explain to me how I can solve this question please
Write a computer program.
The program will let the user enter ten numbers, using the keyboard.
You are to take each input value and store them in a vector
Then, look at that vector and remove any duplicate numbers.
Then, output each number from the vector to the screen.
for (int x; V1.size() < 10; )
cin >> x;
for(int i = 0; i < V1.size(); ++i)
if (i == 0 || V1[i - 1] != V1[i])
cout << V1[i] << " ";
I put cin.get() instead of getch() simply because my Visual Studio 2017 doesn't recognize getch. I'm probably not using a header or something.
The first "for" statement will read the first ten integers and put it into the vector. So even if you put more than ten, it'll just take the first ten.
After sorting, the second "for" followed by "if" statements is what will check for repeating values. First it checks to see if it's the first integer in the vector and prints it, then it checks to see if each integer after is equal to the one before it and only print if it isn't.