Skip to content

Commit

Permalink
Update ex9_20.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Mooophy authored and pezy committed Jun 24, 2015
1 parent 6be14b2 commit e9005ef
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions ch09/ex9_20.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,18 @@
#include <iostream>
#include <deque>
#include <list>

using std::deque; using std::list; using std::cout; using std::cin; using std::endl;

int main()
{
list<int> l{1,2,3,4,5,6,7,8,9,10};
deque<int> d_odd, d_even;
for (auto iter = l.cbegin(); iter != l.cend(); ++iter)
(*iter & 0x1 ? d_odd : d_even).push_back(*iter);
list<int> l{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
deque<int> odd, even;
for (auto i : l)
(i & 0x1 ? odd : even).push_back(i);

for (auto i : d_odd)
cout << i << " ";
for (auto i : odd) cout << i << " ";
cout << endl;
for (auto i : d_even)
cout << i << " ";
for (auto i : even)cout << i << " ";
cout << endl;

return 0;
Expand Down

0 comments on commit e9005ef

Please sign in to comment.