Advertisement
STANAANDREY

power_of_STL

Jul 3rd, 2019
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.08 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. void set_demo()
  5. {
  6.       set<int> s;
  7.     set<int>::iterator it;
  8.     for (int i=0; i<10; i++)
  9.         s.insert(10-i);
  10.     for (it=s.begin(); it!=s.end(); it++)
  11.         cout<<*it<<' ';
  12.     cout<<endl;
  13.     //stergeri & inlocuiri
  14.     set<int>::iterator itr;
  15.     itr=s.find(6);
  16.     s.erase(itr);
  17.     itr=s.find(3);
  18.     s.insert(1);
  19.    if (!s.empty())
  20.     for (it=s.begin(); it!=s.end(); it++)
  21.         cout<<*it<<' ';
  22.     s.clear();
  23.     if (s.empty())
  24.         cout<<"set is empty"<<endl;
  25.         ///ordonare
  26. set <int, greater <int> > gquiz1;
  27.     gquiz1.insert(40);
  28.     gquiz1.insert(30);
  29.     gquiz1.insert(60);
  30.     gquiz1.insert(20);
  31.     gquiz1.insert(50);
  32.     gquiz1.insert(50);
  33.     gquiz1.insert(10);
  34.  
  35.     // printing set gquiz1
  36.     set <int, greater <int> > :: iterator it2;
  37.     cout << "\nThe set gquiz1 is : ";
  38.     for (it2 = gquiz1.begin(); it2 != gquiz1.end(); ++it2)
  39.     {
  40.         cout << '\t' << *it2;
  41.     }
  42.     cout << endl;
  43. }
  44.  
  45. void multiset_demo()
  46. {
  47.  
  48.  
  49. }
  50.  
  51. int main()
  52. {
  53. set_demo();
  54.  
  55.  
  56.     return 0;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement