Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <list>
- using namespace std;
- int main()
- {
- setlocale(LC_ALL, "ru");
- list<char> lst1, lst2;
- int i;
- for (i = 0; i < 10; i += 2)
- lst2.push_back('A' + i);
- for (i = 1; i < 11; i += 2)
- lst2.push_back('A' + i);
- cout << "Содержимое первого списка: ";
- list<char>::iterator p = lst1.begin();
- while (p != lst1.end()) {
- cout << *p;
- p++;
- }
- cout << endl;
- cout << "Содержимое второго списка: ";
- p = lst2.begin();
- while (p != lst2.end()) {
- cout << *p;
- p++;
- }
- cout << endl;
- // Слияние двух списков
- lst1.merge(lst2);
- if (lst2.empty())
- cout << "Теперь второй список пуст\n";
- cout << "Содержимое первого списка после слияния: \n";
- p = lst1.begin();
- while (p != lst1.end()) {
- cout << *p;
- p++;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement