Playground
#include <iostream> #include <list> using namespace std; int main() { list<int> l1; list<int> l2; for (int i=0; i<5; i++) l1.push_back(i); //l1={0, 1, 2, 3, 4} for (int i=4; i<10; i+=2) l2.push_back(i); //l2={4, 6, 8} list<int>::iterator it = l1.begin(); it++; //it pokazuva na '1' vo listata l1 l1.splice(it, l2); //l1={0, 4, 6, 8, 1, 2, 3, 4} //tuka l2={}, bidejki site elementi se premestija vo l1 l2.push_back(6); //l2={6} l2.push_back(4); //l2={6, 4} l1.sort(); //l1={0, 1, 2, 3, 4, 4, 6, 8} l2.sort(); //l2={4, 6} l2.merge(l1); //l2={0, 1, 2, 3, 4, 4, 4, 6, 6, 8} //tuka l1={}, bidejki site elementi se premestija vo l2 cout << l2.size() << endl; //pechati '10' return 0; }
Input data
Program output
no input
Execute
Language: ????????? | Memory: ???? KB | Time: ??? ms
Nothing has been executed, yet!