嘿,我将此 C# 代码转换为 c++
void bubbleSort(int *inputArray, int passStartIndex, int currentIndex,int length)
{
    if(passStartIndex == length - 1) return;
    if(currentIndex == length - 1) return bubbleSort(inputArray, passStartIndex+1, passStartIndex+1,length);
    //compare items at current index and current index + 1 and swap if required
    int nextIndex = currentIndex + 1;
    if(inputArray[currentIndex]>inputArray[nextIndex])
    {
        int temp = inputArray[nextIndex];
        inputArray[nextIndex] = inputArray[currentIndex];
        inputArray[currentIndex] = temp;
    }
    return bubbleSort(inputArray, passStartIndex, currentIndex + 1,length);
}
但是当我在长度为 50100 的输入数组上执行它时,它显示了我的期望
System.StackOverflowException 未处理消息:example.exe 中发生了“System.StackOverflowException”类型的未处理异常
我究竟做错了什么?如何解决?