Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdlib>
- #include <iostream>
- #include <time.h>
- #include <list>
- #include <iterator>
- using namespace std;
- int main()
- {
- //STL list container
- list<int> intList;
- //STL list container iterator
- list<int>::iterator it;
- //Seed random generator
- srand((unsigned)time(NULL));
- //Insert 10 random items into the list container
- for(int i = 0; i < 10; i++)
- intList.insert(++intList.begin(),(rand() % 200 + 1));
- //Print container
- cout << "10 random items in the list container" << endl;
- for(it = intList.begin(); it != intList.end(); ++it)
- cout << (*it) << " ";
- cout << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement