-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfastsortfor.c
61 lines (55 loc) · 1008 Bytes
/
fastsortfor.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
57
58
59
60
61
#include<stdio.h>
void test(int *a)
{
int pivot = 0;
int key = a[pivot];
int flag = 0;
int flag1 = 0;
for (int i = 5; i >= 0; i--)
{
if (i>pivot&&a[i] < key)
{
int tmp = a[i];
a[i] = key;
a[pivot] = tmp;
pivot = i;
flag = i;
break;
}
}
for (int j = 0; j < 6; j++)
{
if (j<pivot&&a[j]>key)
{
int tmp = a[j];
a[j] = key;
a[pivot] = tmp;
pivot = j;
flag1 = j;
break;
}
}
if (flag != flag1)
{
test(a);
}
else
{
return;
}
}
void main()
{
int aa[5] = { 1, 2, 3, 4, 5 };
printf("%x",aa);
printf("%x", &aa);
int *ptr = (int *)(&aa+1);
printf("%d,%d", *(aa + 1), *(ptr-1));//Êä³ö£º2,5
int a[6] = {6,2,7,3,8,9};
test(a);
for (int c = 0; c < 6; c++)
{
printf("%d", a[c]);
}
getchar();
}