C语言之直接插入排序

Posted hmm0530

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了C语言之直接插入排序相关的知识,希望对你有一定的参考价值。

#include void DirectInsertSort(int *Array,int ElementLength) int i,j,temp,k; for(i = 1; i < ElementLength; i++) temp = Array[i]; for(j = i -1 ; j >=0 && temp < Array[j]; j--) Array[j+1] = Array[j]; Array[j+1] = temp; for(k = 0; k < 5; k++) printf("%d ",Array[k]); printf("\r\n"); int main(void) int k = 0; int Array[5] = 3,4,0,1,2; DirectInsertSort(Array,5);

以上是关于C语言之直接插入排序的主要内容,如果未能解决你的问题,请参考以下文章