/* 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 ". */
Void printcontainer (list <int >:: const_iterator, list <int >:: const_iterator); // The output function is used to test
Void printcontainer (deque <int >:: const_iterator, deque <int >:: const_iterator); // reload an Input Function
Int main ()
{
List <int> ilist;
Int aint;
While (CIN> aint) // end with ^ Z, that is, CTRL + z
{
Ilist. push_back (aint );
}
Printcontainer (ilist. Begin (), ilist. End ());
Deque <int> evendeque, odddeque;
For (list <int >:: const_iterator ilistfirst = ilist. Begin (), ilistlast = ilist. End ();
Ilistfirst! = Ilistlast; ++ ilistfirst)
{
If (* ilistfirst % 2) // judge the parity, equivalent to If (* ilistfist % 2 = 1)
Odddeque. push_back (* ilistfirst );
Else
Evendeque. push_back (* ilistfirst );
}
Cout <"odddeque :";
Printcontainer (odddeque. Begin (), odddeque. End ());
Cout <"evendeque :";
Printcontainer (evendeque. Begin (), evendeque. End ());
Return 0;
}
Void printcontainer (list <int >:: const_iterator first, list <int >:: const_iterator last)
{
Cout <Endl;
For (; first! = Last; ++ first)
{
Cout <* First <"";
}
Cout <Endl;
}
Void printcontainer (deque <int >:: const_iterator first, deque <int >:: const_iterator last)
{
Cout <Endl;
For (; first! = Last; ++ first)
{
Cout <* First <"";
}
Cout <Endl;
}