摘要: #include#include#define STACK_INIT_SIZE 100#define STACKINCREMENT 10using namespace std;typedef struct BiTNode{struct BiTNode *lchild;struct BiTNode *rchild;int data;}BiTNode,*BiTree;typedef struct{BiTree *top;BiTree *base;int stack_size;}SqStack;bool InitStack(SqStack &s){s.base = (BiTree *)mal 阅读全文
posted @ 2014-02-14 15:17 c plus plus 阅读(404) 评论(0) 推荐(0)
摘要: #define OVERFLOW -2#define ERROR 0#define NULL 0#define true 1#define TRUE 1#define false 0#define FALSE 0#define STACK_INIT_SIZE 100#define STACKINCREMENT 10#include #include /*初始化迷宫,1表示通道,0表示墙*/int maze[8][8] = { 1,1,0,1,1,1,0,1, 1,1,0,1,1,1,0,1, 1,1,1,1,0,0,1,1, 1,0,0,0,1,1,1,1, 1,1,1,0,1,1,1,1.. 阅读全文
posted @ 2014-02-14 10:22 c plus plus 阅读(294) 评论(0) 推荐(0)
摘要: #includeusing namespace std;void print(int *arr,int length){for(int i = 0;i < length;i++){cout<<arr[i]<<"\t";}cout<<"\n";}void merge(int *arr1,int *arr2,int i,int m,int n){for(int j = m + 1,k = i; i <=m && j <= n;k++){if(arr1[i] < arr1[j]){ar 阅读全文
posted @ 2014-02-14 10:21 c plus plus 阅读(110) 评论(0) 推荐(0)
摘要: #include#includeusing namespace std;void print(int *arr,int length){for(int i = 0;i arr[max])max = lchild;if(rchild arr[max])max = rchild;if(max != i){swap(arr[max],arr[i]);heapAdjust(arr,max,length);}}}void sort(int *arr,int length){for(int i = length/2 -1 ;i >= 0; i--){heapAdjust(arr,i,length); 阅读全文
posted @ 2014-02-14 10:20 c plus plus 阅读(102) 评论(0) 推荐(0)
摘要: #includeusing namespace std;void print(int *l,int length){for(int i = 0;i = media)high--;l[low] = l[high];while(low < high && l[low] <= media)low++;l[high] = l[low];}l[low] = media;return low;}void partition(int *l,int low,int high){int pos ;if(low < high){pos = sort(l,low,high);//p 阅读全文
posted @ 2014-02-14 10:19 c plus plus 阅读(121) 评论(0) 推荐(0)
摘要: #includeusing namespace std;void print(int *arr,int length){for(int i = 0;i 0){for(int i = 0 ; i = 0 && temp < arr[i-step]){arr[i] = arr[i-step];i -=step;}arr[i] = temp;}step -= 2;}}int main(){int arr[] = {8,5,7,4,6,2,3,1,9};int size = sizeof(arr)/sizeof(int);cout<<"排序前数组元素为:&q 阅读全文
posted @ 2014-02-14 10:18 c plus plus 阅读(116) 评论(0) 推荐(0)
摘要: #includeusing namespace std;void print(int *arr,int length){for(int i = 0;i = 0 && temp < arr[times]){arr[times+1] = arr[times];times--;}arr[++times] = temp;}}int main(){int arr[] = {8,5,7,4,6,2,3,1,9};int size = sizeof(arr)/sizeof(int);cout<<"排序前数组元素为:"<<endl;print( 阅读全文
posted @ 2014-02-14 10:06 c plus plus 阅读(126) 评论(0) 推荐(0)
摘要: #includeusing namespace std;void print(int *arr,int length){for(int i = 0;i < length;i++){cout<<arr[i]<<"\t";}cout<<"\n";}void sort(int *arr,int length){int pos = 0;int min = 0;int temp = 0;for(int i = 0; i < length -1;i++){min = arr[i];pos = i;for(int j = 阅读全文
posted @ 2014-02-14 10:05 c plus plus 阅读(120) 评论(0) 推荐(0)
摘要: #includeusing namespace std;void print(int *arr,int length){for(int i = 0;i i;j--){if(arr[j-1] > arr[j]){temp = arr[j];arr[j] = arr[j-1];arr[j-1] = temp;}}}}int main(){int arr[] = {8,5,7,4,6,2,3,1,9};int size = sizeof(arr)/sizeof(int);cout<<"排序前数组元素为:"<<endl;print(arr,size); 阅读全文
posted @ 2014-02-14 10:04 c plus plus 阅读(132) 评论(0) 推荐(0)
摘要: 1、工厂模式:客户类和工厂类分开。消费者任何时候需要某种产品,只需向工厂请求即可。消费者无须修改就可以接纳新产品。缺点是当产品修改时,工厂类也要做相应的修改。如:如何创建及如何向客户端提供。 2、建造模式:将产品的内部表象和产品的生成过程分割开来,从而使一个建造过程生成具有不同的内部表象的产品对象。建造模式使得产品内部表象可以独立的变化,客户不必知道产品内部组成的细节。建造模式可以强制实行一种分步骤进行的建造过程。 3、工厂方法模式:核心工厂类不再负责所有产品的创建,而是将具体创建的工作交给子类去做,成为一个抽象工厂角色,仅负责给出具体工厂类必须实现的接口,而不接触哪一个产品类应当被实例化.. 阅读全文
posted @ 2014-02-14 09:49 c plus plus 阅读(343) 评论(0) 推荐(0)