-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathSorting_Containers.cpp
More file actions
42 lines (42 loc) · 1.05 KB
/
Sorting_Containers.cpp
File metadata and controls
42 lines (42 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <iostream>
#include <list>
#include <cstdlib>
using namespace std;
int main()
{
int choice, item;
list<int> lt;
list<int>::iterator it;
while (1)
{
cout<<"\n---------------------"<<endl;
cout<<"Sorting Containers Implementation in Stl"<<endl;
cout<<"\n---------------------"<<endl;
cout<<"1.Insert Element into the List"<<endl;
cout<<"2.Display Sorted Elements"<<endl;
cout<<"3.Exit"<<endl;
cout<<"Enter your Choice: ";
cin>>choice;
switch(choice)
{
case 1:
cout<<"Enter the element to be inserted: ";
cin>>item;
lt.push_back(item);
break;
case 2:
lt.sort();
cout<<"Elements of Sorted List: ";
for (it = lt.begin(); it != lt.end(); ++it)
cout <<" "<< *it;
cout << endl;
break;
case 3:
exit(1);
break;
default:
cout<<"Wrong Choice"<<endl;
}
}
return 0;
}