We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
/** * 算法拆分组合 用1和0 的移位去做控制 * (这块需要你打印才能看的出来) * * @param len * @param n * @return */ private static ArrayList<Integer[]> getCombFlags(int len, int n) { if (n <= 0) { return new ArrayList<>(); } ArrayList<Integer[]> aResult = new ArrayList<>(); Integer[] aFlag = new Integer[len]; boolean bNext = true; int iCnt1 = 0; //初始化 for (int i = 0; i < len; i++) { aFlag[i] = i < n ? 1 : 0; Log.e(TAG, "getCombFlags:初始化===aFlag["+i+"]== "+ aFlag[i]); }
aResult.add(aFlag.clone()); while (bNext) { iCnt1 = 0; for (int i = 0; i < len - 1; i++) { if (aFlag[i] == 1 && aFlag[i + 1] == 0) { for (int j = 0; j < i; j++) { aFlag[j] = j < iCnt1 ? 1 : 0; Log.e(TAG, "getCombFlags:aFlag["+j+"]== "+ aFlag[j]); } aFlag[i] = 0; aFlag[i + 1] = 1; Integer[] aTmp = aFlag.clone(); aResult.add(aTmp); if (!TextUtils.join("", aTmp).substring(len - n).contains("0")) { bNext = false; } break; } if (aFlag[i] == 1) { iCnt1++; } } } Log.e(TAG, "getCombFlags:aResult=== "+aResult ); return aResult; }
The text was updated successfully, but these errors were encountered:
这段代码的意思是拆分sku的所有可能的组合,你可以试着一个一个打印出来看看
Sorry, something went wrong.
No branches or pull requests
/**
* 算法拆分组合 用1和0 的移位去做控制
* (这块需要你打印才能看的出来)
*
* @param len
* @param n
* @return
*/
private static ArrayList<Integer[]> getCombFlags(int len, int n) {
if (n <= 0) {
return new ArrayList<>();
}
ArrayList<Integer[]> aResult = new ArrayList<>();
Integer[] aFlag = new Integer[len];
boolean bNext = true;
int iCnt1 = 0;
//初始化
for (int i = 0; i < len; i++) {
aFlag[i] = i < n ? 1 : 0;
Log.e(TAG, "getCombFlags:初始化===aFlag["+i+"]== "+ aFlag[i]);
}
The text was updated successfully, but these errors were encountered: