文章分类 - Data Structure
摘要:1 const int MAX_VERTEX_NUM = 100; //最大顶点数为100 2 3 typedef struct EdgeNode //边表结点 4 { 5 int adjvex; //该边指向的顶点在顺序表中的位置 6 int weight; //边上的权重 7 struct EdgeNode* next; //下一条边 8 }EdgeNode; ...
阅读全文
摘要:1 #include <cstdio> 2 #include <conio.h> 3 #include <windows.h> 4 typedef char ElemType; 5 6 typedef struct QNode 7 { 8 ElemType data; 9 struct QNode *next; 10 }QNode,*QueuePtr;11 12 typedef struct13 {14 QueuePtr front; //队头指针 15 QueuePtr rear; //队尾指针 16 }LinkQueue;17 18 //创建一个队...
阅读全文
摘要:1 #include <cstdio> 2 #include <cstdlib> 3 #include <windows.h> 4 #define MaxChild 10 5 typedef char ElemType; 6 typedef struct BiTNode 7 { 8 ElemType data; //节点的数据域 9 struct BiTNode *lchild,*rchild; //左右指针 10 }*BiTree;11 12 void visit(ElemType c,int level) //访问二叉树节点,输出...
阅读全文
摘要:1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <math.h> 4 #include <windows.h> 5 #define STACK_INIT_SIZE 20 6 #define STACKINCREMENT 10 7 8 typedef char ElemType; 9 typedef struct10 {11 ElemType *top;12 ElemType *base;13 int stacksize; 14 }sqStack;15 16 //创建一个栈 17 void
阅读全文
摘要:1 #include <cstdio> 2 #include <conio.h> 3 #include <windows.h> 4 #define MaxSize 10 5 typedef int ElemType; //把int定义为ElemType 6 typedef struct 7 { 8 int *elem; 9 int length;10 int listsize; 11 }Sqlist;12 13 void initSqlist(Sqlist *L)14 {15 L->elem=(int*)malloc(MaxSize*sizeof(El
阅读全文
摘要:1 #include <cstdio> 2 #include <windows.h> 3 #define MaxSize 10 4 void insertElem(int Sqlist[],int *len,int i,int x) 5 { 6 int t; 7 if(*len==MaxSize || i<1 || i>*len+1) //检测非法插入 8 { 9 printf("This insert is illegal\n");10 return; 11 }12 for(t=*len-1;t>...
阅读全文

浙公网安备 33010602011771号