Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

c++ doubly linked list

#include <iostream>
#include <list>

// For help in printing lists
std::ostream& operator<<(std::ostream& ostr, const std::list<int>& list) {
    for (const auto &i : list) {
        ostr << ' ' << i;
    }
    return ostr;
}


int main() {

    std::list<int> list1 = { 5,9,1,3,3 };
    std::list<int> list2 = { 8,7,2,3,4,4 };

    list1.sort();
    list2.sort();
    std::cout << "list1:  " << list1 << '
';
    std::cout << "list2:  " << list2 << '
';
    list1.merge(list2);
    std::cout << "merged: " << list1 << '
';

    return 0;
}
Source by algorithms.theroyakash.com #
 
PREVIOUS NEXT
Tagged: #doubly #linked #list
ADD COMMENT
Topic
Name
1+3 =