Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.91 KB | None | 0 0
  1. #include <iostream>
  2. #include <list>
  3. #include <algorithm>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8.     list<int> list1;
  9.     list<int>::iterator iterator1;
  10.  
  11.     cout << "Enter how many numbers do you want to store: ";
  12.     int n{};
  13.     cin >> n;
  14.  
  15.     int currentNum{};
  16.  
  17.     for(int i{}; i < n; ++i){
  18.         cout << "Enter " << (i + 1) << ". number: ";
  19.         cin >> currentNum;
  20.         list1.push_back(currentNum);
  21.     }
  22.  
  23.     for(iterator1 = list1.begin(); iterator1 != list1.end(); ++iterator1){
  24.         cout << *iterator1 << ", ";
  25.     }
  26.  
  27.     list1.sort();
  28.  
  29.     cout << endl;
  30.  
  31.     for(iterator1 = list1.begin(); iterator1 != list1.end(); ++iterator1){
  32.         cout << *iterator1 << ", ";
  33.     }
  34.  
  35.     cout << endl;
  36.  
  37.     cout << "Size is: " << list1.size() << endl;
  38.  
  39.     auto result = max_element(list1.begin(), list1.end());
  40.  
  41.     cout << "Max element is: " << *result << endl;
  42.  
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement