//Lists are sequence containers that allow non-contiguous memory allocation.
// As compared to vector, the list has slow traversal,
//but once a position has been found, insertion and deletion are quick.
#include <stdio.h>
#include <iterator>
#include <list>
using namespace std;
// function for printing the elements in a list
void showlist(list<int> g)
{
//using scope resolution(::)
list<int>::iterator it;
printf("\n");
for (it = [Link](); it != [Link](); ++it)
printf("%d ",*it);
// Driver Code
int main()
{
list<int> list1, list2 = {3,15,9, 18,6,12, 27,24,21, 30};
for (int i = 1; i <= 10; ++i)
{ list1.push_back(i * 2);
// list2.push_front(i * 3);
}
printf("\nList 1 (list1) is : ");
showlist(list1);
printf("\nList 2 (list2) is : ");
showlist(list2);
printf("\[Link]() : %d",[Link]());
printf( "\[Link]() : %d",[Link]());
//
list1.pop_front(); // pop one element to front
list1.pop_front();
showlist(list1);
//
printf("\nlist2.pop_back() : ");
list2.pop_back();
showlist(list2);
//
printf("\n\[Link]() : ");
[Link]();
showlist(list1);
//
printf("\[Link](): ");
[Link]();
showlist(list1);
return 0;
}