Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Приклад 9
- forward_list<int> c1, c2, c3, c4;
- forward_list<int>::iterator c1_Iter, c2_Iter, c3_Iter, w_Iter, f_Iter, l_Iter;
- c1.push_front(10); c1.push_front(11);
- c2.push_front(12); c2.push_front(20); c2.push_front(21);
- c3.push_front(30); c3.push_front(31);
- c4.push_front(40); c4.push_front(41); c4.push_front(42);
- cout << "c1 =";
- for (c1_Iter = c1.begin(); c1_Iter != c1.end(); c1_Iter++)
- cout << " " << *c1_Iter;
- cout << endl;
- cout << "c2 =";
- for (c2_Iter = c2.begin(); c2_Iter != c2.end(); c2_Iter++)
- cout << " " << *c2_Iter;
- cout << endl;
- w_Iter = c2.begin();
- w_Iter++;
- c2.splice_after(w_Iter, c1);
- cout << "Після splice c1 в c2: c2 =";
- for (c2_Iter = c2.begin(); c2_Iter != c2.end(); c2_Iter++)
- cout << " " << *c2_Iter;
- cout << endl;
- //Приклад 10
- c2.sort(greater<int>());
- cout << "Після сортування c2 : c2 =";
- for (c2_Iter = c2.begin(); c2_Iter != c2.end(); c2_Iter++)
- cout << " " << *c2_Iter;
- cout << endl;
- cout << "c3 =";
- for (c3_Iter = c3.begin(); c3_Iter != c3.end(); c3_Iter++)
- cout << " " << *c3_Iter;
- cout << endl;
- c2.merge(c3, greater<int>());
- cout << "Після merge c3 з c2 відповідно до відношення порівння '>' : c2 =" << endl;
- for (c2_Iter = c2.begin(); c2_Iter != c2.end(); c2_Iter++)
- cout << " " << *c2_Iter;
- cout << endl;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement