### Check repeated elements in a vector

Hi, I've been self-studying c++ for about a month and I'm reading "Programming: Principles and Practice Using C++", I am at the end of chapter 4 and I've learnt some conditional statements, loops, functions and vectors and now I have come across this exercise:
---------- Write a program where you first enter a set of name·and·value pairs,
such as Joe 17 and Barbara 22. For each pair, add the name to a vector
called names and the number to a vector called scores (in corresponding
positions, so that if names[7]=="Joe" then scores[7]==17). Terminate
input by the line No more ("more" will make the attempt to read another
integer fail ). Check that each name is unique and terminate with an error
message if a name is entered twice. Write out all the (name,score) pairs,
one per line.
----------
So I have done the easy part but can't think of a way to solve the part it asks to terminate with an error if a name is entered twice.
I know that there are functions out there that can easily solve this but the book has not covered them yet, so how am I suppose to do this with what I have already learnt ? is this book asking me to research about solutions that it has not taught yet or I need to read these 4 chapters again ?
 ``12345678910111213141516171819202122`` ``````#include #include int main() { std::vector all_names; std::vector all_scores; std::string names; int scores; std::cout<<"Please enter a name followed by it's score\n"; while(std::cin>>names>>scores && names!="No more"){ all_names.push_back(names); all_scores.push_back(scores); } for(int i=0; i
It can be done with what you've already learned. Though keep in mind that that particular book does occasionally expect you to do some independent digging to find solutions.

Before pushing the name and scores inside the while loop, insert another loop that will run through the current vectors and check if the entered name already exists. If it exists, display error message. If it doesn't, push the new values onto vectors.
 ``12345678910111213141516171819`` `````` while(std::cin>>names>>scores && names!="No more"){ bool valid = true; for( int i = 0; i < all_names.size(); i++ ) { if( all_names[i] == names ) { valid = false; } } if( valid ) { all_names.push_back(names); all_scores.push_back(scores); } else { cout << "\nduplicate name"; } }``````