My Blog

Thoughts, tutorials, and insights on technology and development

快速排序

#include <stdio.h> #include <stdlib.h> int Partition (int A[], int low , int high) {   int pivot = A[low];   while (low < high) {     while ...
Read More

归并排序

#include <stdio.h> #include <stdlib.h> int *B; void Merge (int A[], int low, int mid, int high) {   int i,j,k;   for (k = low; k<= high; k++) {   &nb...
Read More

堆排序

#include <stdio.h> #include <stdlib.h> void HeadAdjust (int A[], int k, int len) {   A[0] = A[k];   for (int i = 2*k; i<=len; i *=2) {     i...
Read More

希尔排序

#include <stdio.h> #include <stdlib.h> void shell_sort (int A[],int N) {   int gap,j,k;   for (gap = N/2; gap > 0 ; gap/=2) {     for (j = g...
Read More

插入排序

#include <stdio.h> #include <stdlib.h> void Insertion_sort (int A[], int N) {   int i;   for (i = 1;i < N; i++) {     int key = A[i];  ...
Read More