#include <iostream>
#include <list>
#include <cstdlib>
using namespace std;
int main()
{
list<int> listObject;
int i;
for(i = 0; i < 10; i++)
listObject.push_back(rand());
cout << "Original contents:\n";
list<int>::iterator p = listObject.begin();
while(p != listObject.end()) {
cout << *p << " ";
p++;
}
cout << endl << endl;
listObject.sort();
cout << "Sorted contents:\n";
p = listObject.begin();
while(p != listObject.end()) {
cout << *p << " ";
p++;
}
return 0;
}
|