fork download
  1. #include <vector>
  2. #include <string>
  3. #include <iostream>
  4. #include <iomanip>
  5. #include <set>
  6.  
  7. using namespace std;
  8.  
  9.  
  10. int main(int argc, const char * argv[])
  11. {
  12. set<int> s = { 5,4,3,2,1};
  13. for(int i: s) cout << i << " "; cout << endl;
  14. for(const int& i: s) if (i%2 == 0) ((int&)i)+=5;
  15. for(int i: s) cout << i << " "; cout << endl;
  16.  
  17. s.insert(7);
  18. for(int i: s) cout << i << " "; cout << endl;
  19.  
  20.  
  21. }
  22.  
Success #stdin #stdout 0s 4576KB
stdin
Standard input is empty
stdout
1 2 3 4 5 
1 7 3 9 5 
1 7 3 7 9 5