How to implement insertion sorting in C language
This article mainly explains "how to achieve insertion sorting in C language". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought. Let's study and learn "how to achieve insertion sorting in C language"!
Program code:
# include # include / / insert sort void InsertSort (int * a _ dint len); / / elements in the output array void OutputArray (int * a _ r int len); void main () {int a [7] = {2, 9, 5, 4, 8, 1, 6}; / / element printf in the output array ("data before sorting:"); OutputArray (aQuin7); / / insert sort InsertSort (aPert 7) / / output the sorted result printf ("sorted data:"); OutputArray (aMagne7); system ("pause");} / / insert the sorted void InsertSort (int * a dint len) {for (int item1inti)