Quick sorting: The algorithm used to search for the internet yesterday. Today, C # is used for implementation. It's really fast.
Simple Description: The first input parameter is the array to be sorted. Here I write the reference transfer and use the ref modifier. In fact, it is not critical to pass the reference here, the second and third Parameters specify the start and end points to be sorted. Of course, they are all sorted in full order. Just point to the array header and end. Pay attention to num. length. Do not forget to subtract one. Otherwise, the array will be out of bounds. The array starts from 0 ~
Private void checknumoredasc (ref int [] num, int left, int right)
{
Int I = left;
Int J = right;
Int temp;
Int middle;
Middle = num [(right + Left)/2];
While (Num [I] <middle) & (I <right ))
{
I ++;
}
While (Num [J]> middle) & (j> left ))
{
J --;
}
If (I <= J)
{
Temp = num [I];
Num [I] = num [J];
Num [J] = temp;
I ++;
J --;
}
If (left <j)
{
Checknumoredasc (ref num, left, J );
}
If (Right> I)
{
Checknumoredasc (ref num, I, right );
}
}