/* Here I will write down some of my answers and comments for the exercises in C ++ primer 4th (Note: I didn't buy an answer book, so it is not guaranteed that it is correct. What do you think is wrong, I hope you can tell me) the requirements for source code running are the same as those in the book. The pre-compilation and using lines are omitted. If you still don't know what to say, you can ask me, but I am also a beginner and may not know, I know that I am a beginner when I am still studying C ++ Prime. You are welcome to repost it, but please keep the author's name "jiutian Yuling ". */
Vector <int >:: iterator findint (vector <int >:: iterator, vector <int >:: iterator, INT );
Int main ()
{
Vector <int> ivec;
For (INT I = 0; I! = 10; ++ I)
{
Ivec. push_back (I );
}
Vector <int>: iterator iiterator = ivec. Begin (), iterb = ivec. End ();
Vector <int>: iterator iterc = findint (iiter, iterb, 3); // you can try different calls by yourself
Cout <* iterc;
Return 0;
}
Vector <int >:: iterator findint (vector <int >:: iterator itbegin, vector <int >:: iterator itend,
Int aint) // This is the program
{
For (; itbegin! = Itend; ++ itbegin)
{
If (* itbegin = aint)
{
Return itbegin;
}
}
Cout <"Data couldn't be found." <Endl;
Return -- itend; // note that itend points to the next element of the last element and cannot be called *.
}
// Note: In 9.15, you only need to convert all the vectors into a list.