C语言插入排序算法

#include <stdio.h>

#define kCount 10

int main()

{

    int array[kCount] = {92, 77, 67, 8, 6, 84, 55, 85, 43, 67};

      for (int i = 1; i<kCount; i++) {     

        int temp = array[i];

        int j = i-1;

        while (temp<array[j]) { 

            array[j+1] = array[j];

            j--;

            if (j==-1) {

                break;

            }

        }

        array[j+1] = temp;       

        }  

    for (int i = 0; i<kCount; i++) {      

        printf("%d ", array[i]);

    }

    return 0;

}

原文地址:https://www.cnblogs.com/-boy/p/4029844.html