Linked List

#include <iostream>
#include <list>
using namespace std;
int main()
{
      list < int > x;
      x.push_back(8);
      x.push_back(9);
      x.push_front(6);
      x.insert(++x.begin(),7);
      x.push_back(10);
      list <int>::iterator i;
      for(i=x.begin(); i!=x.end();i++)
      {
          cout<<*i<<endl;
      }
      system("pause");
      return 0;
}

This is the output:
6
7
8
9
10

0 comments:

Post a Comment