-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtools.c
54 lines (45 loc) · 1.72 KB
/
tools.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
void sort_int32( u32 *data , u32 size ){
unsigned int count = (unsigned int) size -1;
register u32 max = 0;
register u32 index = 0;
while (count > 0){
for(u32 i = 0; i < count; i++){
if (data[i] >= max){
max = data[i];
index = i;
}
}
data[index] = data[count];
index = 0;
data[count] = max;
max = 0;
count --;
}
}
unsigned int is_sorted( u32 *data , u32 size){
u32 last = data[0];
u32 current = data[1];
for(u32 i = 2; i < size; i++){
if( current < last ){
return 0;
}else{
last = current;
current = data[i];
}
}
return 1;
}
void sorting_test(){
u32 sorting [] = {12,3,4,3,5,4,24,9,8,7,6,5,4,3,2,1,1,11,14,6,66,8,79,8,81,6,5,7,3,6,8,3,2,2,4,6,8,4,2,2,5,7,8,9,9,4,2,5,5,7,6,8,4,1,
212,98,8457,58789,5,6,8793,5176562,5745,7,9,46,24557,58,9456,26,5,74585,6,6565,6,385,8,56,3748,4562345,249,58078468,6256,5756846,
51,4526,48,4747,245647,6545,627,458,56,4,5152,5,45,6,7,5,45,4526,7,457,68,45,61,2,52,462,45,74,475,2,9847,5,2874,594,8,6720641,7,
4524,579,684,5,79865513,586,50,702360,65,9702,36,5230,516,298749,87,6,2451,98,4756,498,72,8246,207117,4607,4962,4651,265,9,82641865,
14,6529,87,6965194,659,26,4641962,98,65,298,652,98652,46,29,486,52,86,526,59,84,65,9,865165,92,86,598,65,62,984,7519,874,70,23652,
315,162,987,4987,6,245,198,475,649,8728,24,620,7017,460,7496,24,65026,598,264189,84752,984,75,28,745,9486,720,641,74,524,5796,845,6};
u32 zise = sizeof sorting / sizeof (u32);
sort_int32(sorting , zise);
printf("\n");
for( u32 i = 0; i < zise; i++ ){
printf("%u," , sorting[i] );
}
}