Advertisement
SSK007

Untitled

Nov 21st, 2019
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4.  
  5. list<int>ll;
  6.  
  7. list<int> ::iterator cursor=ll.end();
  8.  
  9. void Insert(){
  10.     int y;
  11.     cin>>y;
  12. cursor=ll.insert(cursor,y);
  13. }
  14.  
  15. void Erase(){
  16.    cursor= ll.erase(cursor);
  17.  
  18.  
  19. }
  20. void Move(){
  21.     int y;
  22.     cin>>y;
  23.     if(y>=0){
  24.             for(int i=0;i<y;i++){
  25.         cursor++;}
  26.     }
  27.     else{
  28.         for(int i=y;y<0;i++){
  29.         cursor--;}
  30.     }
  31.     }
  32.  
  33.  
  34.  
  35. int main(){
  36. int x,y,i,j;
  37. int t;
  38. cin>>t;
  39. for(i=0;i<t;i++){
  40.     cin>>x;
  41.     if(x==0)
  42.         Insert();
  43.     else if (x==1)
  44.         Move();
  45.     else if(x==2)
  46.         Erase();
  47. }
  48. for( list<int>::iterator i = ll.begin(); i != ll.end(); i++ ){
  49.         cout << *i << endl;}
  50. return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement