请帮助我(这对于tommorow的学校项目非常方便)
我一直试图在C++中实现递归快速排序算法,但是,当我运行它时,我得到运行时分段错误(窗口):
#include <iostream>
#include <sstream>
#include <stdlib.h>
using namespace std;
void getRandomList(int, int*);
void outputList(int, int*);
void quicksort(int, int*);
int main()
{
cout<<"Quick Sort example, By Jack Wilkie\n";
while (true)
{
cout<<"Please enter list length\n";
string pnput;
cin>>pnput;
cin.ignore(1);
stringstream temp;
temp << pnput;
int length;
temp >> length;
if (length < 1 || length > 100000)
{
cout<<"INVALID INPUT! (0 < input < 100,000)\n";
}
else
{
cout<<"Creating random list of "<<length<<" items\n";
int *list = new int[length]; …
Run Code Online (Sandbox Code Playgroud)