首页 > 编程语言 > 详细

C语言插入排序算法

时间:2014-10-16 23:43:34      阅读:356      评论:0      收藏:0      [点我收藏+]

#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\t", array[i]);

    }

    return 0;

}

C语言插入排序算法

原文:http://www.cnblogs.com/-boy/p/4029844.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!