Advertisement
Mirbek

map, set, iterator

May 5th, 2022
822
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     set < pair <int, int> > st;
  7.     set < pair <int, int> > :: iterator set_it;
  8.     st.insert({1, 0});
  9.     st.insert({3, 0});
  10.     set_it = st.begin();
  11.     cout << set_it->first << endl;
  12.     map <int, int> mp;
  13.     map <int, int> :: iterator it;
  14.  
  15.     mp[2] = 5;
  16.     mp[7] = 10;
  17.     mp[9] = 7;
  18.  
  19.     for (it = mp.begin(); it != mp.end(); it++) {
  20.         cout << it->first << " " << it->second << endl;
  21.     }
  22. }
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement