fork(3) download
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <vector>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8. int n = 7, r = 3;
  9. vector<int> row {40, 40, 40, 50, 50, 60, 100};
  10. vector<bool> v(n);
  11. fill(v.begin() + n - r, v.end(), true);
  12.  
  13. do {
  14. for (int i = 0; i < n; ++i) {
  15. if (v[i]) {
  16. cout << row[i] << " ";
  17. }
  18. }
  19. cout << "\n";
  20. } while (next_permutation(v.begin(), v.end()));
  21. return 0;
  22. }
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
50 60 100 
50 60 100 
50 50 100 
50 50 60 
40 60 100 
40 50 100 
40 50 60 
40 50 100 
40 50 60 
40 50 50 
40 60 100 
40 50 100 
40 50 60 
40 50 100 
40 50 60 
40 50 50 
40 40 100 
40 40 60 
40 40 50 
40 40 50 
40 60 100 
40 50 100 
40 50 60 
40 50 100 
40 50 60 
40 50 50 
40 40 100 
40 40 60 
40 40 50 
40 40 50 
40 40 100 
40 40 60 
40 40 50 
40 40 50 
40 40 40