Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- int main()
- {
- ll t = 1;
- // cin >> t;
- while (t--)
- {
- // multiset<ll> m1; //store in ascending order
- // m1.insert(10); m1.insert(20); m1.insert(1); m1.insert(10);
- // for (auto i : m1) cout << i << " "; cout << endl;
- // cout << m1.count(10) << endl;//frequency of 10
- // m1.erase(10);//erased all instances/occurences of 10
- // for (auto i : m1) cout << i << " "; cout << endl;
- // m1.insert(10); m1.insert(10);
- // for (auto i : m1) cout << i << " "; cout << endl;
- // m1.erase(m1.find(10));//erased only single instance of 10
- // for (auto i : m1) cout << i << " "; cout << endl;
- // auto it1 = m1.begin();
- // cout << *it1 << endl << endl << endl; //or*m1.begin()
- ///////////////////////////////////////////////////////////////////////////////////////
- multiset<ll, greater<ll>> m2; //store in descending order
- m2.insert(10); m2.insert(20); m2.insert(1); m2.insert(10);
- for (auto i : m2) cout << i << " "; cout << endl;
- cout << m2.count(10) << endl;//ferqeuency of 10
- m2.erase(10);//erased all instances of 10
- for (auto i : m2) cout << i << " "; cout << endl;
- m2.insert(10); m2.insert(10);
- for (auto i : m2) cout << i << " "; cout << endl;
- m2.erase(m2.find(10));//erased only single instance of 10
- for (auto i : m2) cout << i << " "; cout << endl;
- auto it2 = m2.begin();
- cout << *it2 << endl;//or*m2.begin()
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement