0 xc00000fd: Stack overflow (x00282f9c x00000001 parameters: 0, 0),
If there are suitable for this exception handler, the program will continue to run safely,
//quick sort algorithm, don't know why, my code to not only sorting sorted array
//for the already sorted array, int a [MAX_SIZE], if you define smaller than MAX_SIZE, call Quick_Sort function is no problem, but if you define MAX_SIZE is larger, the program will appear the error
# include & lt; Iostream>
# include & lt; Iomanip>
using namespace std;
# define MAX_SIZE 10000
Template
Void Quick_Sort (T * a, int left, int right);
Int main ()
{
An int array [MAX_SIZE];
for(int i=0; I
Quick_Sort (array, 0, MAX_SIZE - 1);
System (" pause ");
return 0;
}
Template
A void Quick_Sort (T * and an int left, int right)
{
Int I=left, j=right;
T base=* (a + left);
If (right<=left)
return ;
While (i
While (i
If (i
While (i
If (i
}
If (I==j)
* (a + I)=base;
Quick_Sort (a, left, I - 1);
Quick_Sort (a, I + 1, right);
}
CodePudding user response:
Stack overflow, is often caused by dead recursionCodePudding user response:
Recursive calls, use the Stack, and the size of the Stack is designated by the build system commonly, is not very big, so will Stack overflowTherefore, to deal with large data, do not use recursion
CodePudding user response:
But I call this function does not appear below the case, can you help me explain?Void tree (int v [], int left, int right)
{
Int I, the last;
Void swap (int v [], int, int j);
If (left & gt;=right)
return;
The last=left;
For (I=left + 1; I & lt;=right; I++)
If (v [I]
Swap (v, left, the last);/* restore partition elem */
Tree (v, left, the last - 1);
Tree (v, last + 1, right);
}
Void swap (int v [], int, int j)
{
int temp;
Temp=v [I];
V=v [I] [j];
V [j]=temp;
}
CodePudding user response:
This is the same number and recursive algorithm, a stack overflow, another is not the caseCodePudding user response:
Typography is not?CodePudding user response:
What layout??