vector<vector<int>> Group(const vector<vector<int>>& vec)
{
vector<vector<int>> curResult;
//对第一个赋值
int nlen = vec[0].size();
for (int i = 0; i < nlen; ++i)
{
vector<int> vecTmp; vecTmp.push_back(vec[0][i]);
curResult.push_back(vecTmp);
}
nlen = vec.size();
for (int i = 1; i < nlen; ++i)
{
vector<vector<int>> newCurResult;
const vector<int>& curSelectVec = vec[i];
int jjlen = curSelectVec.size();
for (int jj = 0; jj < jjlen; ++jj)
{
int curResultSize = curResult.size();
for (int curIndex = 0; curIndex < curResultSize; ++curIndex)
{
vector<int> curVecVec = curResult[curIndex];
curVecVec.push_back(curSelectVec[jj]);
newCurResult.push_back(curVecVec);
}
}
curResult = newCurResult;
}
return curResult;
}
输入:{{1,2},{3,4}}
输出:{{1,3},{1,4},{2,3},{2,4}}