Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <algorithm>
- #include <vector>
- using namespace std;
- int n, k;
- vector <int> c;
- void rec(int ind) {
- if (c.size() == k) {
- for (auto i : c) cout << i << " ";
- cout << "\n";
- return;
- }
- for (int i = ind; i <= n; ++i) {
- c.push_back(i);
- rec(i + 1);
- c.pop_back();
- }
- }
- int main() {
- cin >> n >> k;
- rec(1);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement