Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<list>
- using namespace std;
- int main() {
- list<int> l;
- int n = 100;
- for(int i = 0; i < n; i++) {
- l.push_back(i);
- }
- list<int>::iterator it = l.end();
- it--;
- for(; !l.empty(); it--) {
- cout << "the size of l is " << (int) l.size() << endl;
- l.erase(it);
- }
- }
- #include<iostream>
- #include<list>
- using namespace std;
- int main() {
- list<int> l;
- int n = 100;
- for(int i = 0; i < n; i++) {
- l.push_back(i);
- }
- list<int>::iterator it = l.end();
- it--;
- for(; !l.empty();) {
- cout << "the size of l is " << (int) l.size() << endl;
- l.erase(it--);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement