抱歉,您的浏览器无法访问本站
本页面需要浏览器支持(启用)JavaScript
了解详情 >

Dekel'Blog

奔赴山海,保持热爱

线性表

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
//静态顺序表
int MaxSize = 10;
typedef struct{
ElemType data[MaxSize];
int length;
}SqList;

//动态顺序表
int InitSize;
typedef struct{
ElemType* data;
int MaxSize;
int length;
}SeqList;

//单链表
typedef struct LNode{
ElemType data;
struct LNode *next;
}LNode, *LinkList;

//双向链表
typedef struct DNode{
ElemType data;
struct DNode *prior, *next;
}DNode, *DLinkList;

1
2
3
4
5
typedef struct {
SElemType *base;
SElemType *top;
int stacksize;
}SqStack;

队列

1
2
3
4
5
6
7
8
9
10
11
#define MAXQSIZE 100
typedef struct QNode{
QElemType data;
struct QNode *next;
}QNode, *QueuePtr;


typedef struct{
QueuePtr front;
Queueptr rear;
}LinkQueue;

1
2
3
4
5
#define MAXLEN 255
typedef struct{
char ch[MAXSIZE+1];
int length;
}SString;

数组

1
2
3
4
typedef struct {
int *data;
int length;
}Array;

1
2
3
4
typedef struct TNode{
int data;
struct TNode *left, *right;
}TNode;

二叉树

1
2
3
4
typedef struct BiTNode{
int data;
struct BiTNode *lchide, *rchild;
}BiTNode, *BiTree;

图(邻接表存储)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#define MaxVertexNum 100
//边表结点
typedef struct ArcNode{
int adjvex; //该边所指向的顶点
struct ArcNode *nextarc; //下一条边
// InfoType *info;
}ArcNode;

//定点表结点
typedef struct VNode{
VertexType data; //顶点信息
ArcNode *firstarc; //指向第一条边表结点
}VNode, AdjList[MaxVertexNum];

typedef struct{
AdjList vertices; //邻接表头节点
int vexnum,arcnum;
}ALGraph;

图(邻接矩阵)MGraph

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#define INFINITY INT_MAX
#define MAX_VERTEX_NUM 20
typedef enum {DG, DN, UDG, UDN} GraphKind; //{有向图,有向网,无向图,无向网}
typedef struct ArcCell{
VRType adj; //无权图0,1;带权图 权值
InfoType *info;

}ArcCell, AdjMatrix[MAX_VERTEX_NUM][MAX_VERTEX_NUM];

typedef struct{
VertexType vex[MAX_VERTEX_NUM]; //顶点集合
AdjMatrix arcs; //邻接矩阵
int vexnum,arcnum; // 图的定点数和边数
GraphKind kind; //图的类型
}MGraph;

评论

看完了不如留下点什么吧