private: System::Void histogramEqualizationToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
Raw_Intensity = ConvertBMPToIntensity(Buffer, Width, Height);
int histogram[256] = { 0 };
int equalizedHistogram[256] = { 0 };
int runningSum = 0;
int numberOfPixels = Width * Height;
for (int row = 0; row < Height; row++)
{
for (int column = 0; column < Width; column++)
{
histogram[Raw_Intensity[row * Width + column]]++;
}
}
for (int i = 0; i < 256; i++)
{
runningSum += histogram[i];
int index = round(((runningSum / numberOfPixels) * 255));
equalizedHistogram[index] += histogram[i];
}
}
打印(选择排序(num_list))
[7,8,9,10]
[10,9,8,7,7,9,8,10,7,8,9,10]
我让它与BubbleSort甚至是MergeSort一起工作,但它们非常不同 - 这种交易指数的方法似乎不允许你在变化时使用该功能。看来列表在内存中发生了变化; log.append(A)返回已解决的列表:( 谢谢你的帮助。
哦,是的,我在Anaconda中使用python 3.6
答案 0 :(得分:0)
让它像这样工作。感谢你的建议!
def selectionSort(A):
for i, elem in enumerate(A):
minIndex = i
log.append(A[:])
for j in range(i+1, len(A)):
if A[j] < A[minIndex]:
minIndex = j
if minIndex != i:
A[i], A[minIndex] = A[minIndex], A[i]
while log[-1] == log[-2]:
log.remove(log[-1])
return log
num_list = [10, 9, 8, 7]
log = []
print(selectionSort(num_list))
[[10,9,8,7],[7,9,8,10],[7,8,9,10]]