x2311

Untitled

May 2nd, 2022
923
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include <iostream>
  2. #include <list>
  3. #include <iterator>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8.     list<string> mylist;
  9.     cout << "Dntry in the list is not yet empty\nDrive elements through the center\n--- == break\n\n";
  10.     string st;
  11.     cin >> st;
  12.     mylist.push_back(st);
  13.     while (1){
  14.         cin >> st;
  15.         if(st == "---"){
  16.             break;
  17.         }
  18.         mylist.push_back(st);
  19.     }
  20.     cout << "End\n\n";
  21.  
  22.     mylist.reverse();
  23.     copy (mylist.begin(), mylist.end(), ostream_iterator<string>(cout," "));
  24. }
  25.  
  26.  
Advertisement
Add Comment
Please, Sign In to add comment