Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int n, k;
- int arr[100];
- void f(int p, int last) {
- if (p == k) {
- for (int i = 0; i < k; i++)
- cout << arr[i] << " ";
- cout << endl;
- return;
- }
- if (k - p > n - last)
- return;
- for (int i = last+1; i <= n; i++) {
- arr[p] = i;
- f(p+1, i);
- }
- }
- int main() {
- freopen("output.txt","w",stdout);
- cin >> n >> k;
- f(0, 0);
- }
Advertisement
Add Comment
Please, Sign In to add comment