Advertisement
bogolyubskiyalexey

Untitled

Jan 19th, 2021
523
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.77 KB | None | 0 0
  1. int main() {
  2.     std::vector<int> a;
  3.     std::vector<int> b;
  4.    
  5.     /*
  6.         - switch X, X = {1,2}
  7.         - add Y
  8.         - show
  9.         - pop
  10.     */
  11.     std::string s;
  12.     vector<int>* current = &a;
  13.     while (std::cin >> s) {
  14.         if (s == "switch") {
  15.             int num;
  16.             std::cin >> num;
  17.             if (num == 1) {
  18.                 current = &a;
  19.             } else {
  20.                 current = &b;
  21.             }
  22.         } else if (s == "add") {
  23.             int y;
  24.             std::cin >> y;
  25.             current->push_back(y);
  26.         } else if (s == "show") {
  27.             for (auto elem : *current) {
  28.                 std::cout << elem << " ";
  29.         } else {
  30.             current->pop_back(); // ั…ะฐะนะฟ.
  31.         }
  32.     }
  33.  
  34.    
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement