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.
#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;
}
Comments
Leave a comment