Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
33 lines (28 loc) · 1.02 KB

File metadata and controls

33 lines (28 loc) · 1.02 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
#include <iostream>
#include <list>
using namespace std;
int main()
{
list<int> a(8, 10); //fills a list 4 places with 10
list<int> mylist(a.begin(), a.end()); //copies a to mylist
list<int>::iterator i;
for (i = mylist.begin(); i != mylist.end(); ++i) //begin and end function works similar to the vector
cout << *i << "\t";
// front and back function also work similar to the vector functions
mylist.pop_front(); //remove from the front of the list
mylist.pop_back(); //remove from the back of the list
mylist.push_front(20); //inserts value to the front of the list
mylist.push_back(30); //insetts value to the back of the list
cout << endl;
for (i = mylist.begin(); i != mylist.end(); ++i)
cout << *i << "\t";
cout << endl;
for (int p = 0; p < 8; p++)
cout << mylist[p] << "\t";
cout << endl;
mylist.sort();
mylist.reverse();
for (i = mylist.begin(); i != mylist.end(); ++i)
cout << *i << "\t";
return 0;
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.