# 组合

<p>给定两个整数 <em>n</em> 和 <em>k</em>，返回 1 ... <em>n </em>中所有可能的 <em>k</em> 个数的组合。</p>
<p><strong>示例:</strong></p>
<pre><strong>输入:</strong>&nbsp;n = 4, k = 2<strong><br />输出:</strong>[[2,4],[3,4],[2,3],[1,2],[1,3],[1,4],]</pre>


以下程序实现了这一功能，请你填补空白处内容：

```cpp
#include <bits/stdc++.h>
using namespace std;
class Solution
{
public:
	vector<vector<int>> combine(int n, int k)
	{
		vector<vector<int>> res;
		dfs(n, k, 1, res);
		return res;
	}
private:
	vector<int> stack;
	void dfs(int n, int k, int start, vector<vector<int>> &res)
	{
		if (stack.size() == k)
		{
			res.push_back(stack);
		}
		else
		{
			for (int i = start; i <= n; i++)
			{
				stack.push_back(i);
				_____________________;
				stack.pop_back();
			}
		}
	}
};
```

## template

```cpp
#include <bits/stdc++.h>
using namespace std;
class Solution
{
public:
	vector<vector<int>> combine(int n, int k)
	{
		vector<vector<int>> res;
		dfs(n, k, 1, res);
		return res;
	}
private:
	vector<int> stack;
	void dfs(int n, int k, int start, vector<vector<int>> &res)
	{
		if (stack.size() == k)
		{
			res.push_back(stack);
		}
		else
		{
			for (int i = start; i <= n; i++)
			{
				stack.push_back(i);
				dfs(n, k, i + 1, res);
				stack.pop_back();
			}
		}
	}
};
```

## 答案

```cpp
dfs(n, k, i + 1, res);
```

## 选项

### A

```cpp
dfs(n, k, i, res);
```

### B

```cpp
dfs(n - 1, k, i - 1, res);
```

### C

```cpp
dfs(n + 1, k, i - 1, res);
```