//这似乎是排列组合的标准写法了已经
class Solution { public: vector<vector<int>> combine(int n, int k) { vector<vector<int>> res; vector<int> add; DFS(res,k,n,add,0); return res; } void DFS(vector<vector<int>>& res,int k,int n,vector<int> &add,int pos){ if(add.size() == k){ res.push_back(add); } else{ for(int i=pos+1;i <= n;i++){ add.push_back(i); DFS(res,k,n,add,i); add.pop_back(); } } } };