Answer to Question #281930 in C++ for BOUSELHA

Question #281930
Program 3:
Write a program which inputs integers to the user, which puts them as and when
measure in a list (List container of the STL), which sorts this list and then displays the
sorted list.







1
Expert's answer
2021-12-22T08:07:29-0500
#include <iostream>
#include <list>


using namespace std;


int main(){
    list<int> l;
    cout<<"Input 10 integers\n";
    for(int i = 0; i < 10; i++){
        int x;
        cin>>x;
        l.push_back(x);
    }
    l.sort();
    cout<<"Sorted list\n";
    for(auto i = l.begin(); i != l.end(); i++){
        cout<<*i<<" ";
    }
    cout<<endl;
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog