From 5eb0d416e6cc765ff97b5e1beea65d221ffcd23a Mon Sep 17 00:00:00 2001 From: Orange33 <631803219@qq.com> Date: Thu, 15 Jun 2017 21:42:17 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E7=AC=AC=E4=B9=9D=E7=AC=AC=E5=8D=81?= =?UTF-8?q?=E6=AC=A1=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main.c" | 45 +++++ .../sort.c" | 180 ++++++++++++++++++ .../sort.h" | 16 ++ .../hash.c" | 154 +++++++++++++++ .../hash.h" | 43 +++++ .../main.c" | 59 ++++++ 6 files changed, 497 insertions(+) create mode 100644 "2017-1/Orange33/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/main.c" create mode 100644 "2017-1/Orange33/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/sort.c" create mode 100644 "2017-1/Orange33/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/sort.h" create mode 100644 "2017-1/Orange33/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/hash.c" create mode 100644 "2017-1/Orange33/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/hash.h" create mode 100644 "2017-1/Orange33/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/main.c" diff --git "a/2017-1/Orange33/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/main.c" "b/2017-1/Orange33/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/main.c" new file mode 100644 index 00000000..285bab7c --- /dev/null +++ "b/2017-1/Orange33/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/main.c" @@ -0,0 +1,45 @@ +#include "sort.h" +int main() +{ + int compare = 0, move = 0; + int length = rand()%30+1; + int *origin = (int*)malloc(length * sizeof(int)); + int *arr = (int*)malloc(length * sizeof(int)); + + printf("随机生成数据:\n"); + input(origin, length); + output(origin, length); + printf("\n"); + + printf("直接插入排序:\n排序后:"); + originArray(arr, origin, length); + InsertSort(arr, length, &compare, &move); + output(arr, length); + outTime(compare, move); + + printf("希尔排序:\n排序后:"); + originArray(arr, origin, length); + ShellSort(arr, length, &compare, &move); + output(arr, length); + outTime(compare, move); + + printf("起泡排序:\n排序后:"); + originArray(arr, origin, length); + BubbleSort(arr, length, &compare, &move); + output(arr, length); + outTime(compare, move); + + compare = 0, move = 0; + printf("快速排序:\n排序后:"); + originArray(arr, origin, length); + int left = 0, count = 0; + QuickSort(arr,left,length-1,count, &compare, &move); + output(arr, length); + outTime(compare, move); + + printf("简单选择排序:\n排序后:"); + originArray(arr, origin, length); + SelectSort(arr, length, &compare, &move); + output(arr, length); + outTime(compare, move); +} \ No newline at end of file diff --git "a/2017-1/Orange33/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/sort.c" "b/2017-1/Orange33/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/sort.c" new file mode 100644 index 00000000..e6a9336d --- /dev/null +++ "b/2017-1/Orange33/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/sort.c" @@ -0,0 +1,180 @@ +#include "sort.h" + +//交换元素 +void Swap(int a, int b) +{ + int tmp = a; + a = b; + b = tmp; +} + +//直接插入排序 +void InsertSort(int *array, int n, int *comp, int *mov) +{ + *comp = *mov = 0; + int i, j; + int tmp; // 待排序元素 + for (i = 0; i < n; i++) + { + tmp = array[i]; + for (j = i - 1; j >= 0 && tmp < array[j]; j--) + { + Swap(array[j], array [j + 1]); + (*mov) += 3; + ++(*comp); + } + array[j + 1] = tmp; + } +} + +//希尔排序 +void ShellSort(int *array, int n, int *comp, int *mov) +{ + *comp = *mov = 0; + int i, j; + int d = n / 2; + int temp; + while (d >= 1) + { + for (i = d; i < n; i++) + { + temp = array[i]; + for (j = i - d; j >= 0 && temp < array[j]; j = j - d) + { + Swap(array[j + d], array [j]); + (*mov) += 3; + ++(*comp); + } + if (array[j + d] != temp) + { + Swap(array[j + d], temp); + (*mov) += 3; + ++(*comp); + } + } + d /= 2; + } +} + +//起泡排序 +void BubbleSort(int *array, int n, int *comp, int *mov) +{ + *comp = *mov = 0; + int i, j; + int flag = 1; //标记循环过程是否进行过交换,如果为1则进行了交换 + for (i = 0; i < n && flag; i++) + { + flag = 0; + for (j = 1; j < n - i; j++) + { + if (array[j - 1] > array[j]) + { + Swap(array[j], array[j - 1]); + (*mov) += 3; + flag = 1; + } + ++(*comp); + } + } +} + +//快速排序 +void QuickSort(int *array, int left, int right, int count, int *comp, int *mov) +{ //left 和 count初始值为0 right 初始值为数组长度 - 1 + int i; + int count_temp = count + 1; + if (left < right) + { + int base = array[left]; + while (left < right) + { + while (left < right && base < array[right]) + { + right--; + (*comp)++; + } + + array[left] = array[right]; + (*mov)++; + + while (left < right && array[left] < base) + { + left++; + (*comp)++; + } + array[right] = array[left]; + (*mov)++; + } + + array[left] = base; + i = left; + QuickSort(array, left, i - 1, count_temp, comp, mov); + QuickSort(array, i + 1, right, count_temp, comp, mov); + } +} + +//简单选择排序 +void SelectSort(int * array, int n, int *comp, int *mov) +{ + *comp = *mov = 0; + int i, j; + int tmp; //记录待排序元素的下标 + for (i = 0; i < n - 1; i++) + { + tmp = i; + for (j = i + 1; j < n; j++) + { + if (array[tmp] > array[j]) + { + tmp = j; + } + ++(*comp); + } + if (tmp != i) + { + Swap(array[tmp], array[i]); + (*mov) += 3; + } + + } +} + +//随机生成测试数据 +void input(int *a, int n) +{ + srand((unsigned)time(NULL)); + for (int i = 0; i < n; ++i) + { + a[i] = rand() % 100 + 1; + } +} + +//打印输出测试数据 +void output(int* a, int n) +{ + for (int i = 0; i < n; ++i) + { + printf("%d ", a[i]); + } + printf("\n"); + +} + +//输出次数 +void outTime(int comp, int mov) +{ + printf("比较次数: %d\n", comp); + printf("移动次数: %d\n", mov); + printf("二者之和: %d\n", comp + mov); + comp = mov = 0; + printf("\n"); +} + +//初始数组保存 +void originArray(int* array, int* origin, int n) +{ + for (int i = 0; i < n; ++i) + { + array[i] = origin[i]; + } +} \ No newline at end of file diff --git "a/2017-1/Orange33/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/sort.h" "b/2017-1/Orange33/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/sort.h" new file mode 100644 index 00000000..e2883162 --- /dev/null +++ "b/2017-1/Orange33/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/sort.h" @@ -0,0 +1,16 @@ +#pragma once +#include +#include +#include + +void Swap(int a, int b); //交换元素 +void InsertSort(int *array, int n, int *comp, int *mov); //直接插入排序 +void ShellSort(int *array, int n, int *comp, int *mov); //希尔排序 +void BubbleSort(int *array, int n, int *comp, int *mov); //起泡排序 +void QuickSort(int *array, int left, int right, int count, int *comp, int *mov);//快速排序 +void SelectSort(int * array, int n, int *comp, int *mov);//简单选择排序 +void input(int *a, int n); //随机生成测试数据 +void output(int *a, int n ); //打印输出测试数据 +void outTime(int comp, int mov); //输出次数 +void originArray(int* dest, int* source, int n);//初始数组保存 + diff --git "a/2017-1/Orange33/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/hash.c" "b/2017-1/Orange33/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/hash.c" new file mode 100644 index 00000000..7289da8a --- /dev/null +++ "b/2017-1/Orange33/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/hash.c" @@ -0,0 +1,154 @@ +锘#include "hash.h" + +int hashsize[] = { 11,19,29,37 };///鍝堝笇琛ㄥ閲忛掑琛 涓涓悎閫傜殑绱犳暟搴忓垪 +int m = 0;//鍝堝笇琛ㄨ〃闀 鍏ㄥ眬鍙橀噺 + +ElemType newElemType(KeyType key, ValueType value) +{ + ElemType temp = { key,value }; + return temp; +} +int initHashTable(HashTable *H) +{ + int i; + (*H).count = 0;//褰撳墠鍏冪礌涓暟涓0 + (*H).size_index = 0;//鍒濆瀛樺偍瀹归噺涓篽ashsize[0] + m = hashsize[0]; + (*H).elem = (ElemType *)malloc(m * sizeof(ElemType)); + if (!(*H).elem) + exit(0);//瀛樺偍鍒嗛厤澶辫触 + for (i = 0; i < m; i++) + (*H).elem[i].key = NULLKEY;//鏈~璁板綍鐨勬爣璁 + + return 1; +} + +/*閿姣佸搱甯岃〃*/ +void destroyHashTable(HashTable *H) +{ + free((*H).elem); + (*H).elem = NULL; + (*H).count = 0; + (*H).size_index = 0; +} + +/* 涓涓畝鍗曠殑鍝堝笇鍑芥暟(m涓鸿〃闀 鍏ㄥ眬鍙橀噺)*/ +unsigned Hash(KeyType K) +{ + return K%m; +} + +/*绾挎ф帰娴嬪啀鏁e垪*/ +void collision(int *p, int d) +{ + collisiontime = 0; + *p = (*p + d) % m; + collisiontime++;//寮鏀惧畾鍧娉曞鐞嗗啿绐 +} + +/* 鍦ㄥ紑鏀惧畾鍧鍝堝笇琛℉涓煡鎵惧叧閿爜涓篕鐨勫厓绱,鑻ユ煡鎵炬垚鍔,浠鎸囩ず寰呮煡鏁版嵁 */ +/* 鍏冪礌鍦ㄨ〃涓綅缃,骞惰繑鍥濻UCCESS;鍚﹀垯,浠鎸囩ず鎻掑叆浣嶇疆,骞惰繑鍥濽NSUCCESS */ +/* c鐢ㄤ互璁″啿绐佹鏁帮紝鍏跺垵鍊肩疆闆讹紝渚涘缓琛ㄦ彃鍏ユ椂鍙傝 */ +int searchHash(HashTable H, KeyType K, int *p, int *c) +{ + *p = Hash(K);//姹傚緱鍝堝笇鍦板潃 + while (H.elem[*p].key != NULLKEY && !EQ(K, H.elem[*p].key))//璇ヤ綅缃腑濉湁璁板綍 骞朵笖鍏抽敭瀛椾笉鐩哥瓑 + { + (*c)++; + if (*c < m) + collision(p, *c);//姹傚緱涓嬩竴鎺㈡煡鍦板潃p + else + break; + } + if EQ(K, H.elem[*p].key) + return SUCCESS;//鏌ユ壘鎴愬姛 p杩斿洖寰呮煡鏁版嵁鍏冪礌浣嶇疆 + else + return UNSUCCESS;//鏌ユ壘涓嶆垚鍔(H.elem[p].key==NULLKEY p杩斿洖鐨勬槸鎻掑叆鐨勪綅缃) +} + +void recreateHashTable(HashTable *H)//閲嶅缓鍝堝笇琛 +{ + int i, count = (*H).count; + ElemType *p, *elem = (ElemType *)malloc(count * sizeof(ElemType)); + p = elem; + printf("\n閲嶅缓鍝堝笇琛╘n\n"); + for (i = 0; i < m; i++)//淇濆瓨鍘熸湁鐨勬暟鎹埌elem涓 + if (((*H).elem + i)->key != NULLKEY)//璇ュ崟鍏冩湁鏁版嵁 + *p++ = *((*H).elem + i); + (*H).count = 0; + (*H).size_index++;//澧炲ぇ瀛樺偍瀹归噺 + m = hashsize[(*H).size_index]; + p = (ElemType *)realloc((*H).elem, m * sizeof(ElemType)); + if (!p) + exit(0);//瀛樺偍鍒嗛厤澶辫触 + (*H).elem = p; + for (i = 0; i < m; i++) + (*H).elem[i].key = NULLKEY;//鏈~璁板綍鏍囧織锛堝垵濮嬪寲锛 + for (p = elem; p < elem + count; p++)//灏嗗師鏈夌殑鏁版嵁鎸夌収鏂扮殑琛ㄩ暱鎻掑叆鍒伴噸寤虹殑鍝堝笇琛ㄤ腑 + insertHash(H, *p); +} + +/* 鏌ユ壘涓嶆垚鍔熸椂鎻掑叆鏁版嵁鍏冪礌e鍒板紑鏀惧畾鍧鍝堝笇琛℉涓紝骞惰繑鍥1 */ +/* 鑻ュ啿绐佹鏁拌繃澶э紝鍒欓噸寤哄搱甯岃〃 */ +int insertHash(HashTable *H, ElemType e) +{ + int c, p; + + c = 0; + if (searchHash(*H, e.key, &p, &c))//琛ㄤ腑宸叉湁涓巈鏈夌浉鍚屽叧閿瓧鐨勫厓绱 + return DUPLICATE; + else if (c < hashsize[(*H).size_index] / 2)//鍐茬獊娆℃暟c鏈揪鍒颁笂绾 c鐨勯榾鍊煎彲璋 + { + (*H).elem[p] = e;//鎻掑叆e + ++(*H).count; + return 1; + } + else + { + recreateHashTable(H);//閲嶅缓鍝堝笇琛 + } + return 0; +} + +/* 鎸夊搱甯屽湴鍧鐨勯『搴忛亶鍘嗗搱甯岃〃 */ +void traverseHash(HashTable H, void(*Vi)(int, ElemType)) +{ + int i; + printf("鍝堝笇鍦板潃0~%d\n", m - 1); + for (i = 0; i < m; i++) + { + if (H.elem[i].key != NULLKEY)//鏈夋暟鎹 + Vi(i, H.elem[i]); + else + { + H.elem[i].key = -1; + H.elem[i].val = 0; + Vi(i, H.elem[i]); + } + } +} + +/* 鍦ㄥ紑鏀惧畾鍧鍝堝笇琛℉涓煡鎵惧叧閿爜涓篕鐨勫厓绱,鑻ユ煡鎵炬垚鍔,浠鎸囩ず寰呮煡鏁版嵁 */ +/* 鍏冪礌鍦ㄨ〃涓綅缃,骞惰繑鍥濻UCCESS;鍚﹀垯,杩斿洖UNSUCCESS */ +int find(HashTable H, KeyType K, int *p) +{ + int c = 0; + *p = Hash(K);//姹傚緱鍝堝笇鍦板潃 + while (H.elem[*p].key != NULLKEY && !EQ(K, H.elem[*p].key))//璇ヤ綅缃腑濉湁璁板綍锛庡苟涓斿叧閿瓧涓嶇浉绛 + { + c++; + if (c < m) + collision(p, c); //姹傚緱涓嬩竴鎺㈡煡鍦板潃p + else + return UNSUCCESS; // 鏌ユ壘涓嶆垚鍔(H.elem[p].key==NULLKEY) + } + if EQ(K, H.elem[*p].key) + return SUCCESS; //鏌ユ壘鎴愬姛锛宲杩斿洖寰呮煡鏁版嵁鍏冪礌浣嶇疆 + else + return UNSUCCESS; // 鏌ユ壘涓嶆垚鍔(H.elem[p].key==NULLKEY) +} + +void printHash(int p, ElemType r) +{ + printf("{ [%d] : %d->%d }\n", p, r.key, r.val); +} \ No newline at end of file diff --git "a/2017-1/Orange33/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/hash.h" "b/2017-1/Orange33/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/hash.h" new file mode 100644 index 00000000..b350f42d --- /dev/null +++ "b/2017-1/Orange33/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/hash.h" @@ -0,0 +1,43 @@ +#pragma once +#include +#include +#include + +#define SUCCESS 1 +#define UNSUCCESS 0 +#define DUPLICATE -1 + +#define NULLKEY -1//无记录标志 +#define N 10//数据元素个数 + +#define EQ(a,b) ((a)==(b)) + +int collisiontime; + +typedef int KeyType;//设关键字域为整型 +typedef int ValueType; +typedef struct _ElemType { + KeyType key; // 关键字 + ValueType val; // 值 +#ifdef CHAINED_HASH + struct _ElemType *next; +#endif +} ElemType;//数据元素类型 + +typedef struct +{ + ElemType *elem;//数据元素存储基址 动态分配数组 + int count;//当前数据元素个数 + int size_index;//hashsize[size_index]为当前容量 +}HashTable; + +ElemType newElemType(KeyType key, ValueType value); +int initHashTable(HashTable *H); +void destroyHashTable(HashTable *H); +unsigned Hash(KeyType K); +int searchHash(HashTable H, KeyType K, int *p, int *c); +int insertHash(HashTable *H, ElemType e);//对函数的声明 +void recreateHashTable(HashTable *H);//重建哈希表 +void traverseHash(HashTable H, void(*Vi)(int, ElemType)); +int find(HashTable H, KeyType K, int *p); +void printHash(int p, ElemType r); \ No newline at end of file diff --git "a/2017-1/Orange33/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/main.c" "b/2017-1/Orange33/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/main.c" new file mode 100644 index 00000000..bde46b51 --- /dev/null +++ "b/2017-1/Orange33/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/main.c" @@ -0,0 +1,59 @@ +#include "hash.h" + +int main() +{ + ElemType r[N]; + for (int i = 0; i < N; i++) + { + r[i] = newElemType(rand() % 100, rand() % 100); + } + HashTable h; + int i, p; + int j; + KeyType k; + initHashTable(&h); + for (i = 0; i < N - 1; i++)//插入前N-1个记录 + { + j = insertHash(&h, r[i]); + printf("已插入元素:{%d,%d}\t", r[i].key, r[i].val); + printf("冲突次数:%d\n", collisiontime); + if (j == DUPLICATE) + printf("表中已有关键字尾%d的记录 无法再插入记录(%d %d)\n", r[i].key, r[i].key, r[i].val); + } + printf("\n按哈希地址的顺序遍历哈希表\n"); + traverseHash(h, printHash); + printf("\n\n"); + + int count = 5; + while (count > 0) + { + printf("输入关键字:"); + k = rand() % 100; + j = find(h, k, &p); + printf("%d\n", k); + if (j == SUCCESS) + { + printf("在位置%d找到该元素", p); + printHash(p, h.elem[p]); + } + else + printf("没找到\n"); + k = 0; + count--; + } + j = insertHash(&h, r[i]);//插入第N个记录 + if (j == 0)//j==ERROR 重建哈希表 + { + j = insertHash(&h, r[i]);//重建哈希表后重新插入第N个记录 + } + + printf("按哈希地址的顺序遍历重建后的哈希表\n"); + traverseHash(h, printHash); + printf("\n\n"); + + destroyHashTable(&h); + printf("哈希表销毁成功!"); + printf("\n\n"); + + return 0; +} \ No newline at end of file From 93fbf23395e5d0647f38c30826ff77e84e5b0bb2 Mon Sep 17 00:00:00 2001 From: Orange33 <631803219@qq.com> Date: Wed, 21 Jun 2017 22:24:37 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E7=AC=AC=E4=B9=9D=E6=AC=A1=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=E4=BF=AE=E6=94=B9=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sort.c" | 46 ++++++++++--------- .../sort.h" | 2 +- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git "a/2017-1/Orange33/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/sort.c" "b/2017-1/Orange33/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/sort.c" index e6a9336d..13aa8acc 100644 --- "a/2017-1/Orange33/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/sort.c" +++ "b/2017-1/Orange33/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/sort.c" @@ -1,13 +1,5 @@ #include "sort.h" -//交换元素 -void Swap(int a, int b) -{ - int tmp = a; - a = b; - b = tmp; -} - //直接插入排序 void InsertSort(int *array, int n, int *comp, int *mov) { @@ -19,7 +11,9 @@ void InsertSort(int *array, int n, int *comp, int *mov) tmp = array[i]; for (j = i - 1; j >= 0 && tmp < array[j]; j--) { - Swap(array[j], array [j + 1]); + int arr = array[j + 1]; + array[j + 1] = array[j]; + array[j] = arr; (*mov) += 3; ++(*comp); } @@ -41,13 +35,17 @@ void ShellSort(int *array, int n, int *comp, int *mov) temp = array[i]; for (j = i - d; j >= 0 && temp < array[j]; j = j - d) { - Swap(array[j + d], array [j]); + int arr = array[j + d]; + array[j + d] = array[j]; + array[j] = arr; (*mov) += 3; ++(*comp); } if (array[j + d] != temp) { - Swap(array[j + d], temp); + int arr = array[j + d]; + array[j + d] = temp; + temp = arr; (*mov) += 3; ++(*comp); } @@ -69,7 +67,10 @@ void BubbleSort(int *array, int n, int *comp, int *mov) { if (array[j - 1] > array[j]) { - Swap(array[j], array[j - 1]); + int arr = array[j]; + array[j] = array[j - 1]; + array[j - 1] = arr; + (*mov) += 3; flag = 1; } @@ -117,28 +118,29 @@ void QuickSort(int *array, int left, int right, int count, int *comp, int *mov) void SelectSort(int * array, int n, int *comp, int *mov) { *comp = *mov = 0; - int i, j; - int tmp; //记录待排序元素的下标 - for (i = 0; i < n - 1; i++) + int i, j, k; + for (i = 0; i < n; i++) { - tmp = i; + k = i; for (j = i + 1; j < n; j++) { - if (array[tmp] > array[j]) + if (array[j] < array[k]) { - tmp = j; + k = j; + (*comp)++; } - ++(*comp); } - if (tmp != i) + if (i != k) { - Swap(array[tmp], array[i]); + int arr = array[i]; + array[i] = array[k]; + array[k] = arr; (*mov) += 3; } - } } + //随机生成测试数据 void input(int *a, int n) { diff --git "a/2017-1/Orange33/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/sort.h" "b/2017-1/Orange33/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/sort.h" index e2883162..0582a293 100644 --- "a/2017-1/Orange33/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/sort.h" +++ "b/2017-1/Orange33/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/sort.h" @@ -3,7 +3,7 @@ #include #include -void Swap(int a, int b); //交换元素 + void InsertSort(int *array, int n, int *comp, int *mov); //直接插入排序 void ShellSort(int *array, int n, int *comp, int *mov); //希尔排序 void BubbleSort(int *array, int n, int *comp, int *mov); //起泡排序