fork download
  1. /// no time to waste
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4.  
  5. int n, k;
  6. int a[21];
  7.  
  8. void dequy(int i) {
  9. if(i > k) {
  10. for(int j=1;j<=k;j++) cout << a[j] << ' ';
  11. cout << '\n';
  12. return;
  13. }
  14.  
  15. int rem = k - i + 1;
  16. for(int j=a[i - 1] + 1;j <= n - rem + 1;j++) {
  17. a[i] = j;
  18. dequy(i + 1);
  19. }
  20. return;
  21. }
  22.  
  23. int32_t main() {
  24. ios::sync_with_stdio(false);
  25. cin.tie(0), cout.tie(0);
  26. freopen("tapcon.inp", "r", stdin);
  27. freopen("tapcon.out", "w", stdout);
  28.  
  29. cin >> n >> k;
  30. dequy(1);
  31. return 0;
  32. }
Success #stdin #stdout 0.01s 5316KB
stdin
5 3
stdout
Standard output is empty