摘要: /** * 队列--链式存储 **/#include <stdlib.h>#include <iostream.h>#define OK 1#define ERROR 0typedef struct node { //链式队列的结点结构 int item; //队列的数据元素类型 struct node *next; //指向后继结点的指针}NODE;typedef struct queue{ //链式队列 NODE *front; //队头指针 NODE *rear; ... 阅读全文
posted @ 2013-02-23 17:58 何长春 阅读(175) 评论(0) 推荐(0) 编辑
摘要: /** * 队列--顺序存储 **/#include <stdlib.h>#include <iostream.h>#define OK 1#define ERROR 0//队列的最大数据元素数目#define MAX_QUEUE 10 typedef struct queue{ //假设当数组只剩下一个单元时认为队满 int item[MAX_QUEUE]; //存放队列中数据元素的存储单元 int front,rear; //队头指针、队尾指针}QUEUE;//初始化队列Q void... 阅读全文
posted @ 2013-02-23 17:57 何长春 阅读(195) 评论(0) 推荐(0) 编辑
摘要: /** * 栈--链式存储 **/#include <stdlib.h>#include <iostream.h>#define OK 1#define ERROR 0typedef struct node { //链栈的结点结构 int item; //栈的数据元素类型 struct node *next; //指向后继结点的指针}NODE; typedef struct stack{ NODE *top;}STACK; //初始化栈S void InitStack(STACK *S){ S->top=NULL;}//入栈 voi... 阅读全文
posted @ 2013-02-23 17:56 何长春 阅读(149) 评论(0) 推荐(0) 编辑
摘要: /** * 栈--顺序存储 **/#include <stdlib.h>#include <iostream.h>#define OK 1#define ERROR 0//栈的最大数据元素数目#define MAX_STACK 10 typedef struct stack{ int item[MAX_STACK]; //存放栈中数据元素的存储单元 int top;//栈顶指针}STACK;//初始化栈S void InItStack(STACK *S) { S->top=-1; } //入栈 void Push(STACK *S,int i... 阅读全文
posted @ 2013-02-23 17:55 何长春 阅读(164) 评论(0) 推荐(0) 编辑
摘要: /** * 单链表 **/#include <stdlib.h>#include <iostream.h>#define OK 1#define ERROR 0//结点类型typedef struct node{ int item; struct node *next;}NODE;//链表类型typedef struct{ NODE *head;}LINK_LIST;//初始化单链表int init(LINK_LIST *L){ L->head=(NODE*)malloc(sizeof(NODE)); //为头结点分配存储单元 if (L->head) .. 阅读全文
posted @ 2013-02-23 17:53 何长春 阅读(159) 评论(0) 推荐(0) 编辑
摘要: /** * 线性表 **/#include "stdio.h"#include <stdlib.h>#include <iostream.h>#define LIST_MAX_LENGTH 100 //线性表的最大长度#define OK 1#define ERROR 0//定义线性表结构typedef struct{ int *item; //指向存放线性表中数据元素的基地址 int length; //线性表的当前长度 ... 阅读全文
posted @ 2013-02-23 17:52 何长春 阅读(185) 评论(0) 推荐(0) 编辑