摘要:
#include <stdio.h>#include <stdlib.h>#include <string.h>template <class T>voidmerge(T* array, int left, int mid, int right, T* temp){ int i =left; int j =mid+1; int p=0; while(i<=mid && j <=right){ if(array[i]>array[j]){ temp[p++]=array[j++]; }else{ temp[p++] 阅读全文
摘要:
#include <stdio.h>#include <stdlib.h>template <class T>voidswap(T& a, T& b){ T temp; temp=a; a=b; b=temp;}template <class T>voidpartion(T* array, int left, int right){ if(left >= right ) return; int low=left; int hight=right-1; while(low<=hight){ while(array[low 阅读全文
摘要:
#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( 阅读全文
摘要:
#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 阅读全文