fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. set<pair<int, string>> s = {make_pair(2, "x"), make_pair(3, "y")};
  7.  
  8. // Inserting an element
  9. s.insert(make_pair(1, "z"));
  10.  
  11. // Traversing the set
  12. for (auto x : s)
  13. cout << x.first << " "<< x.second << endl;
  14. return 0;
  15. }
Success #stdin #stdout 0.01s 5280KB
stdin
Standard input is empty
stdout
1 z
2 x
3 y