-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.cpp
65 lines (53 loc) · 1.29 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <iostream>
#include <vector>
#include <sstream>
#include <string>
using namespace std;
int main()
{
int n,i,j,m,x,c,num=0;
cin>>n;
string input ,text;
vector<string> a;
for(i=0;i<n;i++){
cin>>input;
a.push_back(input);
}
int q;
j=n-1;
cin>>q;
for(i=0;i<q;i++){
cin>>input;
if(input[0]==':'){
text=input[1];
num=stoi(text);
j=num-1;
}
else if(input=="dd"){ a.erase(a.begin()+j);
if(j==a.size())
j--;
}
else if(input=="i"){cin>>m;
cin.ignore();
for(x=0;x<m;x++){
getline(cin,text);
a.push_back(text);
}
}
else if(input=="y"){ c=j+1;
}
else if(input=="p") { if(c!=0){
text=a[c-1];
a.push_back(text); }
}
else if(input=="dy") { text=a[j];
a.erase(a.begin()+j);
if(j==a.size())
j--;
}
}
for(i=0;i<a.size();i++){
cout<<a[i]<<endl;
}
return 0;
}