摘要:
#include #include int n; /* * 分割使枢轴记录的左边元素比右边元素小 */ int Partition(int *array, int low, int high) { int pivotkey = array[low]; array[0] = array[low]; while (low = pivotkey) {... 阅读全文
摘要:
#include #include int n; /* * 冒泡排序 */ void BubbleSort(int *array) { int i, j, temp; for (i = 0; i array[j + 1]) { temp = array[j]; array[j] ... 阅读全文
摘要:
#include #include int n; /* * 希尔排序 */ void ShellSort(int *array) { int k = n / 2; //增量序列(仅作举例) while (k > 0) { int i, j; for (i = k + 1; i 0 && array[0] < array[j];... 阅读全文
摘要:
#include #include int n; /* * 直接插入排序 */ void InsertSort(int *array) { int i, j; for (i = 2; i <= n; i++) { if (array[i] < array[i - 1]) { array[0] = arra... 阅读全文
摘要:
#include #include int BinarySearch(int *array, int key, int low, int high) { int mid; while (low <= high) { mid = (low + high) / 2; if (key == array[mid]) { ... 阅读全文
摘要:
#include #include #define TRUE 1 #define FALSE 0 #define OK 1 #define ERROR 0 #define OVERFLOW -2 #define MAX_NUM 20 typedef int Status; typedef int QElemType; typedef char VexType; /* * 邻接表存储结... 阅读全文
摘要:
#include #include #define TRUE 1 #define FALSE 0 #define OVERFLOW -2 #define OK 1 #define ERROR 0 typedef int Status; typedef int TElemType; /* * 存储结构 */ typedef struct BiTNode { TElemType... 阅读全文
摘要:
#include #include #define TRUE 1 #define FALSE 0 #define OK 1 #define ERROR 0 #define OVERFLOW -2 typedef int QElemType; typedef int Status; /* * 存储结构 */ typedef struct QNode { QElemType d... 阅读全文
摘要:
#define TRUE 1 #define FALSE 0 #define OK 1 #define ERROR 0 #define OVERFLOW -2 #define INIT_SIZE 20 #define INCREMENT_SIZE 5 typedef int SElemType; typedef int Status; /* * 存储结构 */ typedef struc... 阅读全文
摘要:
#include #include #define TRUE 1 #define FALSE 0 #define OK 1 #define ERROR 0 #define OVERFLOW -2 typedef int ElemType; typedef int Status; /* * 存储结构 */ typedef struct LNode { ElemType dat... 阅读全文