排序 简单插入法
程序代码:
#include<stdio.h> #include<stdlib.h> #include<string.h> typedef int elemtype; struct_table { int arr[]; }; void insert_sort(int arr[], int length) { int j; int tail; tail = 1; while(tail<table->length) { temp = table->arr[tail]; j = tail - 1; while (j > 1) if (temp.key > table->arr[j].key) table->arr[j + 1] = table->arr[j]; else { table->arr[j + 1] = temp; break; j--; } tail++; } } int main() { int arr[] = { 12,56,21,10,76,43,88,92,38 }; select_sort(arr, sizeof(arr) / sizeof(arr[0])); for (int i = 0;i < sizeof(arr) / sizeof(arr[0]);i++); { printf("%d", arr[i]); } return 0; }
求大神改改