Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <list>
- #include <algorithm>
- using namespace std;
- int main() {
- list<int> list1;
- list<int>::iterator iterator1;
- cout << "Enter how many numbers do you want to store: ";
- int n{};
- cin >> n;
- int currentNum{};
- for(int i{}; i < n; ++i){
- cout << "Enter " << (i + 1) << ". number: ";
- cin >> currentNum;
- list1.push_back(currentNum);
- }
- for(iterator1 = list1.begin(); iterator1 != list1.end(); ++iterator1){
- cout << *iterator1 << ", ";
- }
- list1.sort();
- cout << endl;
- for(iterator1 = list1.begin(); iterator1 != list1.end(); ++iterator1){
- cout << *iterator1 << ", ";
- }
- cout << endl;
- cout << "Size is: " << list1.size() << endl;
- auto result = max_element(list1.begin(), list1.end());
- cout << "Max element is: " << *result << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement