fork download
  1. #include <iostream>
  2. #include <set>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. // Initializing the set
  8. set<char> mySet;
  9. mySet.insert('d');
  10. mySet.insert('a');
  11. mySet.insert('b');
  12. mySet.insert('e');
  13.  
  14. // Declaring the iterator
  15. set<char>::iterator it1;
  16.  
  17. // Iterating through the set and printing elements
  18. for(it1 = mySet.begin(); it1 != mySet.end(); it1++) {
  19. cout << *it1 << " ";
  20. }
  21. cout << endl;
  22.  
  23. return 0;
  24. }
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
a b d e