摘要: #include <stdio.h>#include <stdlib.h>#include <string.h>template <class T>voidcountSort(T* array, int len){ T max = array[0]; T min = array[0]; for(int i =0 ;i<len; ++i){ if(array[i]>=max) max = array[i]; if(array[i]<min) min = array[i]; } T* countArray = (T*)calloc( 阅读全文
posted @ 2011-04-30 10:45 Richard Zhong 阅读(117) 评论(0) 推荐(1) 编辑
摘要: #include <stdio.h>#include <stdlib.h>#include <string.h>template <class T>voidinsert(T* array, int pos){ int i = pos-1; T value = array[pos]; while(i>=0 && array[i]>value){ --i; } memmove((array+i+2), (array+i+1), sizeof(T)*(pos-i-1)); array[i+1] = value;}intmai 阅读全文
posted @ 2011-04-30 09:29 Richard Zhong 阅读(148) 评论(0) 推荐(1) 编辑
摘要: #include <stdio.h>#include <stdlib.h>#include <string.h>#define MAX_STR 10000voidmakeEmpty(char** strset){ memset(strset, 0, MAX_STR*sizeof(char*));}voidinsert_t(char* str_p, char insert, char* str_alloc, int index){ int len = strlen(str_p); strncpy(str_alloc, str_p, len); int nbyt 阅读全文
posted @ 2011-04-28 14:20 Richard Zhong 阅读(969) 评论(0) 推荐(1) 编辑
摘要: 个人菜鸟,发表下对头文件包含顺序的看法:首先是常规的包含:[代码]这是一个在平常不过的包含了,主文件main.cpp包含头文件"a.h",当调用function_a()函数时,由于main.cpp文件中未包含function_a此函数的声明,那么它会到"a.h"这个文件中去找它的声明。如果在"a.h"这个文件中找不到,那么它回到"a.h"所包含的头文件中去找,这样一级一级往上找,直到找到或者找不到... 阅读全文
posted @ 2010-11-13 12:45 Richard Zhong 阅读(6301) 评论(3) 推荐(1) 编辑