随机“排序”的最有效方法(混乱)-C#中的整数列表
bool[] bIndexSet = new bool[iItemCount];for (int iCurIndex = 0; iCurIndex < iItemCount; iCurIndex++){ int iSwapIndex = random.Next(iItemCount); if (!bIndexSet[iSwapIndex] && iSwapIndex != iCurIndex) { int iTemp = values[iSwapIndex]; values[iSwapIndex] = values[iCurIndex]; values[iCurIndex] = values[iSwapIndex]; bIndexSet[iCurIndex] = true; bIndexSet[iSwapIndex] = true; }}
慕标5832272
慕码人8056858
相关分类