fork(4) download
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4.  
  5. using namespace std;
  6.  
  7. struct compareFirstPairMember {
  8. bool operator()(const pair<int, int>& a, const pair<int, int>& b) const {
  9. return a.first < b.first;
  10. }
  11. };
  12.  
  13. int main() {
  14.  
  15. vector<pair<int, int>> v;
  16. v.push_back(pair<int,int>(3,600));
  17. v.push_back(pair<int,int>(2,900));
  18. v.push_back(pair<int,int>(2,800));
  19.  
  20. sort(v.begin(), v.end(), compareFirstPairMember());
  21.  
  22. do {
  23. for(auto item : v)
  24. cout << item.first << " " << item.second << endl;
  25. cout << endl;
  26. } while ( std::next_permutation(begin(v), end(v), [](const pair<int, int>& a, const pair<int, int>& b) { return a.first < b.first; }));
  27.  
  28. return 0;
  29. }
Success #stdin #stdout 0s 3432KB
stdin
Standard input is empty
stdout
2 900
2 800
3 600

2 900
3 600
2 800

3 600
2 800
2 900