#include <iostream>
#include <list>
using std::cout;
using std::endl;
using std::list;
int main()
{
list<int> lst1, lst2;
for (int i = 0; i < 5; i++)
lst1.push_back(i);
for (int i = 0; i < 5; i++)
lst2.push_front(i);
list<int>::iterator p;
p = lst1.begin();
while (p != lst1.end()) {
cout << *p << " ";
p++;
}
cout << endl;
p = lst2.begin();
while (p != lst2.end()) {
cout << *p << " ";
p++;
}
cout << endl;
return 0;
}
/*
run:
0 1 2 3 4
4 3 2 1 0
*/