// C++ program to demonstrate the use of list containers #include #include using namespace std; int main() { // We have a list 1 containing 6 elements //Take the elements out of list 1 and insert them into list 2 //so that the elements in list 2 are sorted. //Do not use a library STL sort function. //Iterate throught the list1 elements and insert into //list2 one element at a time by finding the correct //position for it. //4 2 3 5 1 16 //Take 4 out and put it in list2 // Take 2 out and place it before 4 in list2 list list1 ; list list2 ; list1.push_back( 4 ) ;list1.push_back( 2 ) ; list1.push_back( 3 ) ;list1.push_back( 5 ) ; list1.push_back( 1 ) ; list1.push_back( 16 ) ; list::iterator it = list1.begin() ; list::iterator it2 = list2.begin() ; for( int a1 : list1 ) { cout << a1 << " " ; } cout << endl ; return 0; }