-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinput1.wlp4
34 lines (34 loc) · 1.02 KB
/
input1.wlp4
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
int partition(int* array, int left, int right) {
int pivot = 0; int i = 0; int j = 0;
int temp = 0; int break = 0; int ret = 0;
pivot = *(array+left);
i = left-1; j = right+1;
while(break == 0) {
i = i+1; while(*(array+i) < pivot) { i = i+1; }
j = j-1; while(*(array+j) > pivot) { j = j-1; }
if(i >= j) { ret = j; break = 241; } else {}
if(break != 241) {
temp = *(array+i); *(array+i) = *(array+j); *(array+j) = temp;
} else {}
}
return ret;
}
int fastSort(int* array, int left, int right) {
int skip = 0; int pivot = 0;
if(left < 0) { skip = 1; } else {}
if(right < 0) { skip = 1; } else {}
if(right <= left) { skip = 1; } else {}
if(skip == 0) {
pivot = partition(array, left, right);
skip = fastSort(array, left, pivot);
skip = fastSort(array, pivot+1, right);
} else {}
return 0;
}
int wain(int* a, int b) {
int sort = 0;
int i = 0; while(i<b) { println(*(a+i)); i = i+1; }
sort = fastSort(a,0,b-1);
i = 0; while(i<b) { println(*(a+i)); i = i+1; }
return 0;
}