Code:
#include iostream
#include set
#include string
#include cstdlib
using namespace std;
int main()
{
multiset
multiset
int choice, item;
while (1)
{
cout<<"\n---------------------"<
cout<<"Multiset Implementation in Stl"<
cout<<"\n---------------------"<
cout<<"1.Insert Element into the Multiset"<
cout<<"2.Delete Element from the Multiset"<
cout<<"3.Find Element in a Multiset"<
cout<<"4.Count Elements with a specific key"<
cout<<"5.Size of the Multiset"<
cout<<"6.Display Multiset"<
cout<<"7.Exit"<
cout<<"Enter your Choice: ";
cin>>choice;
switch(choice)
{
case 1:
cout<<"Enter value to be inserted: ";
cin>>item;
if (ms.empty())
it1 = ms.insert(item);
else
it1 = ms.insert(it1, item);
break;
case 2:
cout<<"Enter value to be deleted: ";
cin>>item;
ms.erase(item);
break;
case 3:
cout<<"Enter element to find ";
cin>>item;
it = ms.find(item);
if (it != ms.end())
cout<<"Element found"<
else
cout<<"Element not found"<
break;
case 4:
cout<<"Enter element to be counted: ";
cin>>item;
cout<
break;
case 5:
cout<<"Size of the Multiset: "<
break;
case 6:
cout<<"Elements of the Multiset: ";
for (it = ms.begin(); it != ms.end(); it++)
cout<<*it<<" ";
cout<
break;
case 7:
exit(1);
break;
default:
cout<<"Wrong Choice"<
}
}
return 0;
}
Output:
---------------------
Multiset Implementation in Stl
---------------------
1.Insert Element into the Multiset
2.Delete Element from the Multiset
3.Find Element in a Multiset
4.Count Elements with a specific key
5.Size of the Multiset
6.Display Multiset
7.Exit
Enter your Choice: 1
Enter value to be inserted: 100
---------------------
Multiset Implementation in Stl
---------------------
1.Insert Element into the Multiset
2.Delete Element from the Multiset
3.Find Element in a Multiset
4.Count Elements with a specific key
5.Size of the Multiset
6.Display Multiset
7.Exit
Enter your Choice: 1
Enter value to be inserted: 200
---------------------
Multiset Implementation in Stl
---------------------
1.Insert Element into the Multiset
2.Delete Element from the Multiset
3.Find Element in a Multiset
4.Count Elements with a specific key
5.Size of the Multiset
6.Display Multiset
7.Exit
Enter your Choice: 1
Enter value to be inserted: 300
---------------------
Multiset Implementation in Stl
---------------------
1.Insert Element into the Multiset
2.Delete Element from the Multiset
3.Find Element in a Multiset
4.Count Elements with a specific key
5.Size of the Multiset
6.Display Multiset
7.Exit
Enter your Choice: 1
Enter value to be inserted: 400
---------------------
Multiset Implementation in Stl
---------------------
1.Insert Element into the Multiset
2.Delete Element from the Multiset
3.Find Element in a Multiset
4.Count Elements with a specific key
5.Size of the Multiset
6.Display Multiset
7.Exit
Enter your Choice: 1
Enter value to be inserted: 500
---------------------
Multiset Implementation in Stl
---------------------
1.Insert Element into the Multiset
2.Delete Element from the Multiset
3.Find Element in a Multiset
4.Count Elements with a specific key
5.Size of the Multiset
6.Display Multiset
7.Exit
Enter your Choice: 5
Size of the Multiset: 5
---------------------
Multiset Implementation in Stl
---------------------
1.Insert Element into the Multiset
2.Delete Element from the Multiset
3.Find Element in a Multiset
4.Count Elements with a specific key
5.Size of the Multiset
6.Display Multiset
7.Exit
Enter your Choice: 6
Elements of the Multiset: 100 200 300 400 500
---------------------
Multiset Implementation in Stl
---------------------
1.Insert Element into the Multiset
2.Delete Element from the Multiset
3.Find Element in a Multiset
4.Count Elements with a specific key
5.Size of the Multiset
6.Display Multiset
7.Exit
Enter your Choice: 2
Enter value to be deleted: 300
---------------------
Multiset Implementation in Stl
---------------------
1.Insert Element into the Multiset
2.Delete Element from the Multiset
3.Find Element in a Multiset
4.Count Elements with a specific key
5.Size of the Multiset
6.Display Multiset
7.Exit
Enter your Choice: 5
Size of the Multiset: 4
---------------------
Multiset Implementation in Stl
---------------------
1.Insert Element into the Multiset
2.Delete Element from the Multiset
3.Find Element in a Multiset
4.Count Elements with a specific key
5.Size of the Multiset
6.Display Multiset
7.Exit
Enter your Choice: 6
Elements of the Multiset: 100 200 400 500
---------------------
Multiset Implementation in Stl
---------------------
1.Insert Element into the Multiset
2.Delete Element from the Multiset
3.Find Element in a Multiset
4.Count Elements with a specific key
5.Size of the Multiset
6.Display Multiset
7.Exit
Enter your Choice: 4
Enter element to be counted: 100
100 appears 1 times.
---------------------
Multiset Implementation in Stl
---------------------
1.Insert Element into the Multiset
2.Delete Element from the Multiset
3.Find Element in a Multiset
4.Count Elements with a specific key
5.Size of the Multiset
6.Display Multiset
7.Exit
Enter your Choice: 1
Enter value to be inserted: 100
---------------------
Multiset Implementation in Stl
---------------------
1.Insert Element into the Multiset
2.Delete Element from the Multiset
3.Find Element in a Multiset
4.Count Elements with a specific key
5.Size of the Multiset
6.Display Multiset
7.Exit
Enter your Choice: 6
Elements of the Multiset: 100 100 200 300 400 500
---------------------
Multiset Implementation in Stl
---------------------
1.Insert Element into the Multiset
2.Delete Element from the Multiset
3.Find Element in a Multiset
4.Count Elements with a specific key
5.Size of the Multiset
6.Display Multiset
7.Exit
Enter your Choice: 4
Enter element to be counted: 100
100 appears 2 times.
---------------------
Multiset Implementation in Stl
---------------------
1.Insert Element into the Multiset
2.Delete Element from the Multiset
3.Find Element in a Multiset
4.Count Elements with a specific key
5.Size of the Multiset
6.Display Multiset
7.Exit
Enter your Choice: 7
------------------
(program exited with code: 1)
Press return to continue
More C++ Programs: