摘要:
binaryTree.h 1 #ifndef BINARYTREE_H 2 #define BINARYTREE_H 3 4 #include 5 using namespace std; 6 7 #include 8 #include 9 #include 10 11 enum Status{ERROR,OK};//定义状态枚举时还得注意实际的值,不能搞错了 12 13 template 14 Status PrintElement(T e) 15 { 16 cout 21 class BiNode//树节点 22 { 23 public: 24 B... 阅读全文
摘要:
searchBST.h 1 #ifndef SEARCHBST_H 2 #define SERACHBST_H 3 4 #include 5 #include 6 #include 7 #include 8 9 typedef int ElemType; 10 typedef enum{ERROR,OK}Status; 11 typedef int KeyType; 12 13 typedef struct BiNode 14 { 15 ElemType data; 16 struct BiNode *left,*right; 17 }BiNod... 阅读全文
摘要:
prim1.h 1 #ifndef PRIM_H 2 #define PRIM_H 3 4 //* 普里姆算法,求最小生成树 5 #include 6 #include 7 #include 8 9 #define MAX_VERTEX_NUM 5 10 #define INFINITY 1000//这里不能用INT_MAX,因为如果是整型正数的最大值,加一后反而变成最小值,这点要注意 11 12 typedef int VRType; 13 typedef int VertexType; 14 typedef char InfoType; 15 typedef... 阅读全文
摘要:
main.cpp 1 #include 2 #define max 10001 3 int main() 4 { 5 long s,sum,i,a[max],n,x,y,x1; 6 while(scanf("%ld",&n)>0&&n) 7 { 8 for(i=1;in)21 {22 if(a[x]==0&&a[y]==0)23 printf("0 0 0\n");24 else25 printf("0 %ld %ld\n",a... 阅读全文
摘要:
fcpp.h 1 #ifndef FCCP_H 2 #define FCCP_H 3 4 #include 5 #include 6 #include 7 #include 8 9 typedef int ElemType; 10 11 ElemType position(ElemType a[],ElemType b[],int start,int end); 12 13 void swap(ElemType &a,ElemType &b) 14 { 15 ElemType temp; 16 temp = a; 17 a = b; 1... 阅读全文
摘要:
huffmanTree.h 1 #include 2 #include 3 #include 4 #include 5 6 #define MAXSIZE 10 7 8 typedef struct 9 { 10 unsigned int weight; 11 unsigned int left,right,parent; 12 }HTNode,* HuffmanTree; 13 14 typedef char * * HuffmanCode; 15 16 void Select(HuffmanTree HT,int end,int &s1,i... 阅读全文
摘要:
alGraph.h 1 #ifndef ALGRAPH_H 2 #define ALGRAPH_H 3 4 #include 5 #include 6 #include 7 #include 8 9 #define MAX_VERTEX_NUM 20 10 11 typedef char InfoType; 12 typedef int VertexType; 13 14 typedef enum{ERROR,OK} Status; 15 16 //---图的邻接表存储,本程序中为使用此存储方式 17 typedef struct ArcNode//弧节点 ... 阅读全文
摘要:
biThrTree.h 1 #include 2 #include 3 #include 4 5 typedef int TElemType; 6 typedef enum PointerTag{Link,Thread}; 7 //线索二叉树 8 typedef struct BiThrNode 9 { 10 TElemType data; 11 struct BiThrNode *lchild,*rchild; 12 PointerTag LTag,RTag; 13 }BiThrNode, *BiThrTree; 14 15 BiThrTree ... 阅读全文
摘要:
avlTree.h 1 #ifndef AVLTREE_H 2 #define AVLTREE_H 3 4 #include 5 #include 6 #include 7 #include 8 9 #define LH +1 10 #define EH 0 11 #define RH -1 12 13 typedef int ElemType; 14 typedef struct BSTNode//平衡二叉排序树结构体 15 { 16 ElemType data; 17 int bf; 18 struct BSTNode *lchild... 阅读全文
摘要:
1 #include 2 using namespace std; 3 4 #include 5 #include 6 #include 7 #include 8 9 void swap(int &a,int &b) 10 { 11 int c = a; 12 a = b; 13 b = c; 14 } 15 16 int partition(vector &vs,vector &ve,int start,int end) 17 { 18 int a = vs[start]; 19 int... 阅读全文