//---------------------------------------------------------------- // // list.cpp // // Code to illustrate the use of list. // // written by: Simon Parsons // modified : 5th June 2010 // //---------------------------------------------------------------- #include #include // Remember we need this to use lists using namespace std; //---------------------------------------------------------------- int main() { // Create a list and initialise it with random numbers list L; for ( int i=0; i<10; i++ ) { L.push_front( rand() % 100); } // Print it out. list::iterator p; for ( p = L.begin(); p != L.end(); p++ ) { cout << *p << " "; } cout << endl; // Sort it and print it L.sort(); for ( p = L.begin(); p != L.end(); p++ ) { cout << *p << " "; } cout << endl; }