Rishav_hitk_cse

simpletexteditor

Aug 27th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.83 KB | None | 0 0
  1. #include <cmath>
  2. #include <cstdio>
  3. #include <vector>
  4. #include <iostream>
  5. #include <algorithm>
  6. #include <bits/stdc++.h>
  7.  
  8. using namespace std;
  9.  
  10.  
  11. int main() {
  12.     int t_case,i=0,ip,k;
  13.     string w;
  14.     string s;
  15.     s="";
  16.  
  17.     stack <string> undo;
  18.  
  19.     cin>>t_case;
  20.     while(i<t_case){
  21.         cin>>ip;
  22.         switch(ip){
  23.             case 1:
  24.                 undo.push(s);
  25.                 cin>>w;
  26.                 s=s+w;
  27.                 break;
  28.             case 2:
  29.                 cin>>k;
  30.                 undo.push(s);
  31.                 s.erase(s.end()-k,s.end());
  32.                 break;
  33.             case 3:
  34.                 cin>>k;
  35.                 cout<<s.at(k)<<endl;
  36.             case 4:
  37.                 s=undo.top();
  38.                 undo.pop();
  39.                 break;
  40.  
  41.         }
  42.         i++;
  43.     }
  44.     return 0;
  45. }
Add Comment
Please, Sign In to add comment