hash表C语言实现
摘要:算法参考《算法导论》第11章散列表。采用链地址法解决冲突.#include #include #include #include /*通过链接法解决碰撞*/typedef const char* hash_key_type;typedef int hash_value_type;typedef in...
阅读全文
C语言实现栈
摘要:#include #include #include typedef struct stack_tag{ int top; int num; int *data;} stack;stack * stack_init(int num){ stack *s = (stack*)m...
阅读全文
大数加法
摘要:#include #include #include #include void reverse_str(char *pBegin, char *pEnd){ while(pBegin = 0 || j >= 0)); i--, j--, k++){ int a = i >= 0...
阅读全文
kmp算法
摘要:#include #include #include int kmp(const char *str, const char *str_sub){ int sub_len = strlen(str_sub); if(sub_len == 0){ return 0; ...
阅读全文
最大堆
摘要:根据《算法导论》中介绍的算法实现。 #include #include #include typedef struct priority_queue_tag { int heap_size; int *array;} priority_queue;int parent(int i...
阅读全文
C语言实现快排
摘要:#include void swap(int *pa, int *pb){ int t = *pa; *pa = *pb; *pb = t;}int partion(int *array, int begin, int end){ if (array == NULL || b...
阅读全文