C language, c
1. Fast Sorting Algorithm
1 # include <stdio. h> 2 3 struct node 4 {5 int key; 6}; 7 typedef struct node DataType; 8 9 int Qukpass_sort (DataType Ar [], int s, int t ); 10 int Quk_Sort (DataType Ar [], int s, int t); 11 12 int main (void) 13 {14 15 int n, I; 16 DataType array [20]; 17 18 printf ("Input the length of the array <20>:"); 19 scanf ("% d", & n); 20 for (I = 0; I <n; I ++) // Input array 21 {22 printf ("Input % d datas:", I + 1); 23 scanf ("% d ", & array [I]); 24} 25 26 27 printf ("\ n The array are:"); 28 for (I = 0; I <n; I ++) 29 {30 printf ("% 4d", array [I]); // The input array is 31} 32 33 Quk_Sort (array, 0, n-1 ); // call The Sorting Algorithm 34 35 36 printf ("\ n The array after quicksort are:"); 37 for (I = 0; I <n; I ++) // output the sorted algorithm result 38 {39 printf ("% 4d", array [I]); 40 41} 42 return (0 ); 43} 44 45 46 int Quk_Sort (DataType Ar [], int s, int t) // fast Sorting Algorithm 47 {48 int I; 49 if (s <t) 50 {51 I = Qukpass_sort (Ar, s, t); 52 Quk_Sort (Ar, s, I-1); 53 Quk_Sort (Ar, I + 1, t ); 54 55} 56} 57 58 59 int Qukpass_sort (DataType Ar [], int s, int t) // a division algorithm for quick sorting 60 {61 DataType temp; 62 int low, high; 63 64 low = s; // low indicates the left boundary 65 high = t of the sequence during partitioning; // high indicates the left boundary 66 temp = Ar [s] of the sequence during partitioning. // Save the central axis value to temp67 while (low