Advertisement
Guest User

Untitled

a guest
Dec 18th, 2018
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.89 KB | None | 0 0
  1. #include <iostream>
  2. #include <list>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     setlocale(LC_ALL, "ru");
  9.     list<char> lst1, lst2;
  10.     int i;
  11.     for (i = 0; i < 10; i += 2)
  12.         lst2.push_back('A' + i);
  13.     for (i = 1; i < 11; i += 2)
  14.         lst2.push_back('A' + i);
  15.     cout << "Содержимое первого списка: ";
  16.     list<char>::iterator p = lst1.begin();
  17.     while (p != lst1.end()) {
  18.         cout << *p;
  19.         p++;
  20.     }
  21.     cout << endl;
  22.     cout << "Содержимое второго списка: ";
  23.     p = lst2.begin();
  24.     while (p != lst2.end()) {
  25.         cout << *p;
  26.         p++;
  27.     }
  28.     cout << endl;
  29.     // Слияние двух списков
  30.     lst1.merge(lst2);
  31.     if (lst2.empty())
  32.         cout << "Теперь второй список пуст\n";
  33.     cout << "Содержимое первого списка после слияния: \n";
  34.     p = lst1.begin();
  35.     while (p != lst1.end()) {
  36.         cout << *p;
  37.         p++;
  38.     }
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement