[java]代码库
package ke01;
public class Quick {
public static void quick_sort(int s[], int l, int r)
{
int i, j, x;
if (l < r)
{
i = l;
j = r;
x = s[i];
while (i < j)
{
while(i < j && s[j] > x)
j--;
if(i < j)
s[i++] = s[j];
while(i < j && s[i] < x)
i++;
if(i < j)
s[j--] = s[i];
}
s[i] = x;
quick_sort(s, l, i-1);
quick_sort(s, i+1, r);
}
}
public static void main(String[] args) {
int a[]={49,38,65,97,76,13,27};
int l = 0;
int r = 6;
int i;
quick_sort(a,l,r);
for( i=0;i<=r;i++) {
System.out.print(" "+a[i]);
}
}
}