-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlist1.cpp
More file actions
35 lines (33 loc) · 708 Bytes
/
list1.cpp
File metadata and controls
35 lines (33 loc) · 708 Bytes
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
#include<iostream>
#include<list>
using namespace std;
int main(){
list<int> x;
int n,i;
char k[5];
ios::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
for (i=0;i<n;i++){
cin >> k;
if (k[0] == 'I'){
int v;
cin >> v;
x.push_front(v);
}
else {
int cou=1,b;
cin >> b;
for(auto j = x.begin(); j != x.end() ; j++){
if (cou == b){
x.erase(j);
break;
}
cou++;
}
}
}
for (list<int>::iterator p = x.begin() ; p != x.end() ; p++){
cout << *p << "\n";
}
}