-
Notifications
You must be signed in to change notification settings - Fork 20
/
testInput.c
56 lines (52 loc) · 1.01 KB
/
testInput.c
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
53
54
55
56
void swap(int arr[10], int i, int j) {
int temp;
temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
void quickSort(int a[10], int p, int r) {
int x;
int i;
i = p - 1;
int j;
int t;
int v;
v = r - 1;
if (p < r) {
x = a[r];
for (j = p; j <= v; j++) {
if (a[j] <= x) {
i++;
swap(a, i, j);
}
}
v = i + 1;
swap(a, v, r);
t = v - 1;
quickSort(a, p, t);
t = v + 1;
quickSort(a, t, r);
}
}
void main () {
int a[10];
int i;
int t;
int b;
int g = 5;
for(i = 0; i < 10; i++) {
printf("asd %d", g);
g = g + 1;
}
printf("Array before quicksort:");
for(i = 0; i < 10; i++) {
t = (10 - i);
a[i] = t;
printf("value of a[%d] is %d", i, a[i]);
}
quickSort(a, 0, 9);
printf("Array after quicksort:");
for (i = 0; i < 10; i++) {
printf("value of a[%d] is %d", i, a[i]);
}
}