标签:
root@ubuntu:/mnt/shared/appbox/issort# cat issort.c #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> int issort(int *array, int num) { int i, j, tmp; for(j=1; j<num; j++) { tmp = array[j]; i = j - 1; while( i >= 0 && array[i] > tmp) { array[i+1] = array[i]; i--; } array[i+1] = tmp; } return 0; } int main(int argc, char *argv[]) { int i; int a[10] = {1,3,5,7,9,2,4,6,8}; issort(a, 9); for(i=0; i<9; i++) { printf("%d,", a[i]); } printf("\n"); return 0; }
标签:
原文地址:http://blog.csdn.net/xiangpingli/article/details/43039137