-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIntegetComper.java
More file actions
52 lines (43 loc) · 1.22 KB
/
IntegetComper.java
File metadata and controls
52 lines (43 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package com;
/**
* @author <a href="mailto:daiju3@crnet.com.hk">daiju3</a>
* @version 1.0.0
* @description
* @since 2018/7/12 16:02
*/
public class IntegetComper {
public static Integer max = Integer.MAX_VALUE;
public static void main(String[] args) {
int a[]={1,2,3,42323,213,43323,55555,221332,996};
int start=0;
int end=a.length-1;
System.out.println(a.length);
quickSort(a,start,end);
for(int i:a){
System.out.println(i);
}
}
public static void quickSort(int []a, int low, int high) {
int start = low;
int end = high;
int key = a[low];
while (end > start) {
while (end > start && a[end] >= key)
end--;
if (a[end] <= key) {
int temp = a[end];
a[end] = a[start];
a[start] = temp;
}
while (end > start && a[start] <= key)
start++;
if (a[start] >= key) {
int temp = a[start];
a[start] = a[end];
a[end] = temp;
}
}
if(start>low) quickSort(a,low,start-1);
if(end<high) quickSort(a,end+1,high);
}
}