-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path0.txt
43 lines (40 loc) · 806 Bytes
/
0.txt
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
// Target: qsort
// Possible optimization: Dead code elimination, common expression, strength reduction
// REMARKS: nothing.
//
//
//int a[10100];
int[] a = new int[10100];
int n = 10000;
int qsrt(int l, int r) {
int i = l;
int j = r;
int x = a[(l + r) / 2];
while (i <= j) {
while (a[i] < x) i++;
while (a[j] > x) j--;
if (i <= j) {
int temp = a[i];
a[i] = a[j];
a[j] = temp;
i++;
j--;
}
}
if (l < j) qsrt(l, j);
if (i < r) qsrt(i, r);
return 0;
}
int main() {
int i;
for (i = 1; i <= n; i++)
a[i] = n + 1 - i;
qsrt(1, n);
for (i = 1; i <= n; i++) {
// printf("%d ", a[i]);
print(toString(a[i]));
print(" ");
}
print("\n");
return 0;
}