标签:插入排序 nbsp string matrix oid sort int main col
1 #include<stdio.h> 2 #include<string.h> 3 void insert_sort(int a[], int length) 4 { 5 int key; 6 int j; 7 8 for (int i = 1; i < length; i++) 9 { 10 key = a[i]; 11 j = i - 1; 12 13 while (a[j] >key && j >= 0) 14 { 15 a[j + 1] = a[j]; 16 j--; 17 } 18 a[j + 1] = key; 19 20 } 21 int num; 22 for (int i = 0; i < length; i++) 23 { 24 num = a[i]; 25 printf("%d ", num); 26 27 } 28 } 29 int main() 30 { 31 int matrix[6] = { 31,41,59,26,41,58 }; 32 insert_sort(matrix, 6); 33 34 }
标签:插入排序 nbsp string matrix oid sort int main col
原文地址:https://www.cnblogs.com/KIROsola/p/11110526.html