我的代码在放入int main()函数时工作,但当我将其作为另一个函数(void bubbleSort)实现时,输出显示它,就好像没有排序完成一样。冒泡排序输出没有排序
void bubbleSort(int numeros[])
{
int store = 0;
int length = ARRAY_SIZE(numeros);
for(int i=0; i<(length-1); i++)
{
for(int j=0; j<(length-i-1); j++)
{
if(numeros[j] < numeros[j+1])
{
store = numeros[j];
numeros[j] = numeros[j+1];
numeros[j+1] = store;
}
}
}
for(int m=0; m<1000; m++)
{
cout << numeros[m] <<' ';
}
}
我可能做错了什么?任何帮助将不胜感激。
'int length = ARRAY_SIZE(numeros);' - 把'std :: cout << length << std :: endl;'放在它后面。这可能会告诉你问题 –