Insertion sorting method implemented with C, first enter 10 numbers, then use the insertion sort method to be sorted, and output the result. The algorithm is simple, and it is available for beginners.
#include "stdio.h" #include "cono.h" main () {int a [10], r [11]; int * p; int I, j; for (i = 0; i <10; i ) {P = & a [I]; Printf ("please scan the no:% d / n", I); scanf ("% d", p); R [i 1] = a [i];} R [ 0] = 1; for (i = 2; i <= 10; i ) {r [0] = R [i]; j = I-1; while (r [j]> r [0]) {r [ J 1] = r [J]; J-;} R [J 1] = R [0];
For (i = 1; i <= 10; i ) {p = & r [I]; Printf ("Form min to max the no:% d value =% d / n", i, * p);}
Getch ();