fork download
  1. #include <iostream>
  2. #include <list>
  3. using namespace std;
  4.  
  5. void printList(list<int> &l) {
  6. for (auto it = l.begin();it != l.end(); it++) {
  7. cout<<*it<<" ";
  8. }
  9. cout<<endl;
  10. }
  11.  
  12. void findMax(list<int> &l) {
  13. l.sort();
  14. printList(l);
  15. }
  16.  
  17. int main() {
  18. list<int> l;
  19. l.push_back(3);
  20. l.push_back(1);
  21. l.push_back(4);
  22. l.push_back(1);
  23. l.push_back(5);
  24. l.push_back(9);
  25. printList(l);
  26.  
  27. findMax(l);
  28.  
  29. return 0;
  30. }
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
3 1 4 1 5 9 
1 1 3 4 5 9