随笔分类 -  Data Structure

some code about DS .
数据结构(C语言版)---第三章栈和队列 3.4.2 队列的链式表示和实现(循环队列)
摘要:这个是循环队列的实现,至于串及数组这两章,等有空再看,下面将学习树。源码如下:#include #include #define MAXQSIZE 8typedef int QElemType ;typedef struct{ QElemType *base; int front; int rear;}SqQueue;int InitSqQueue(SqQueue *S){ S->base = (QElemType *)malloc(sizeof(QElemType)*MAXQSIZE); printf("Init %p\n",S->base); if(!S.. 阅读全文

posted @ 2013-06-20 12:07 净坛使者 阅读(698) 评论(0) 推荐(0)

数据结构(C语言版)---第三章栈和队列 3.4.2 队列的链式表示和实现(单链表)
摘要:只是实现了简单的算法,了解队列的FIFO,源码如下:#include <stdio.h>#include <stdlib.h>typedef int QElemType ;typedef short Status;typedef struct QNode{ QElemType data; struct QNode * next;}QNode,*QueuePtr;typedef struct { QueuePtr front; QueuePtr rear;}LinkQueue;Status InitQueue(LinkQueue *Q){ Q->front = Q- 阅读全文

posted @ 2013-06-19 16:52 净坛使者 阅读(413) 评论(0) 推荐(0)

数据结构(C语言版)---第三章栈和队列 3.3 表达式求值
摘要:主要是参照“算法优先法”改写的。如何判断两个算术运算符之间的优先关系值得借鉴。源码如下:Main_3_3_EvaluateExpression.c#include "Stack_char.h"#include "Stack_float.h"#define OPSETSIZE 7unsigned char Prior[7][7] = { // ±í3.1 Ëã·û¼äµÄÓÅÏȹØÏ&# 阅读全文

posted @ 2013-06-14 15:46 净坛使者 阅读(706) 评论(0) 推荐(0)

数据结构(C语言版)---第三章栈和队列 3.2.4 迷宫求解
摘要:花了一下午时间,完成了纯C语言版的迷宫求解,源码见下:Main_3_2_maze.c:#include "Stack_maze.h"#define ROW 10#define LINE 10Cell c[LINE][ROW];void InitCell(){ int i = 0 ; int j = 0; for(i = 0 ; i < LINE ; i++) { for(j = 0 ; j < ROW ; j++) { c[i][j].pix.x = i; c[i][j].pix.y = j; ... 阅读全文

posted @ 2013-06-13 12:45 净坛使者 阅读(479) 评论(0) 推荐(0)

数据结构(C语言版)---第三章栈和队列 3.2.1 -- 3.2.3 十进制转二进制、括号合法性检测及行编辑
摘要:主要实现了十进制到二进制的转换、对括号的合法性检测以及教材中的行编辑。分别是这三个函数:int Conver10to2(),int IsBracketLegal(char *data),int LineEdit()。具体源码如下:Main_3_2.c:#include "Stack.h"/*3.2.1*/int Conver10to2(){ int data = 0; printf("please input the num :\n"); scanf("%d",&data); while(data < 0) { prin 阅读全文

posted @ 2013-06-09 09:32 净坛使者 阅读(903) 评论(0) 推荐(0)

数据结构(C语言版)---第三章栈和队列 3.1
摘要:主要实现初始化、入栈、出栈、取栈顶值、输出栈内容等5个接口。Stack.h#ifndef _STACK_H#define _STACK_H#include <stdlib.h>#include <string.h>#include <stdio.h>#define STACK_INIT_SIZE 100#define STACK_INCRE_SIZE 50typedef int SElemType ;typedef struct SqStack{ SElemType *base; SElemType *top; int stackSize; }Stack,* 阅读全文

posted @ 2013-06-06 13:08 净坛使者 阅读(367) 评论(0) 推荐(0)

数据结构(C语言版)---第二章2.8-2.11 动态链表
摘要:主要实现以下几个接口:1. 顺序创建动态链表。2. 打印所有链表内容。3. 取得特定位置的链表内容。4. 向指定位置插入链表元素。5. 将两个链表整合成一个链表。具体代码如下,实现还是生成动态库。LinkList.h#ifndef _LINK_LIST_H#define _LINK_LIST_H#include #include #include #define OK 1#define ERROR -1typedef int ElemType;typedef int Status;typedef struct LNode_{ ElemType data; struct LNod... 阅读全文

posted @ 2013-06-05 10:31 净坛使者 阅读(1122) 评论(2) 推荐(0)

数据结构(C语言版)---第二章2.1-2.7
摘要:List.h#ifndef _LIST_H#define _LIST_H#include <stdio.h>#include <stdlib.h>#include <string.h>#define LIST_INIT_SIZE 100#define LIST_INCRE_SIZE 10#define OK 1#define ERROR -1typedef int ElemType;typedef int Status;typedef struct _LIST{ ElemType *elem; int length; int listSize;}List,* 阅读全文

posted @ 2013-06-03 16:02 净坛使者 阅读(474) 评论(7) 推荐(0)

导航