Advertisement
Guest User

Untitled

a guest
Apr 28th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. include <iostream>
  2. #include <list>
  3. #include <iterator>
  4. using namespace std;
  5. void List1(list <int> g)
  6. {
  7. list <int>::iterator it;
  8. for(it = g.begin(); it != g.end(); ++it)
  9. cout << '\t' << *it;
  10. cout << '\n';
  11. }
  12. int main()
  13. {
  14. list <int> list1, list2;
  15.  
  16.  
  17. for (int i = 0; i < 20; ++i)
  18. {
  19. list1.push_back(i*2);
  20. list2.push_front(i*3);
  21. }
  22. cout << "\nList 1 (gqlist1) is : ";
  23. List1(list1);
  24.  
  25. cout << "\nList 2 (gqlist2) is : ";
  26. List1(list2);
  27.  
  28. cout << "\ngqlist1.front() : " << list1.front();
  29. cout << "\ngqlist1.back() : " << list1.back();
  30.  
  31. cout << "\ngqlist1.pop_front() : ";
  32. list1.pop_front();
  33. List1(list1);
  34. return 0;
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement