Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2015
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 KB | None | 0 0
  1.  // This program demonstrates the STL list container.
  2.  #include <iostream>
  3.  #include <list> // Include the list header.
  4.  using namespace std;
  5.  
  6.  int main()
  7.  {
  8.  // Define a list object.
  9.  list<int> myList;
  10.  
  11.  // Define an iterator for the list.
  12.  list<int>::iterator iter;
  13.  
  14.  // Add values to the list.
  15.  for (int x = 0; x < 100; x += 10)
  16.  myList.push_back(x);
  17.  
  18.  // Display the values.
  19.  for (iter = myList.begin(); iter != myList.end(); iter++)
  20.  cout << *iter << " ";
  21.  cout << endl;
  22.  
  23.  // Now reverse the order of the elements.
  24.   myList.reverse();
  25.  
  26.  // Display the values again.
  27.  for (iter = myList.begin(); iter != myList.end(); iter++)
  28.  cout << *iter << " ";
  29.  cout << endl;
  30.  return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement