
算法相关
文章平均质量分 75
劲草
生命冲动的主题是寻求快乐摆脱焦虑
展开
-
二叉树存储结构
/*commen.h 操作二叉树的头文件*/#include "stdlib.h"#include "stdio.h"#include "iostream.h"#include "string.h"# define TRUE 1# define FALSE 0# define NULL 0# define TElemType char# define ElemType BiTree# defin原创 2008-06-08 18:31:00 · 928 阅读 · 0 评论 -
操作二叉树使用的栈
/*BiTree_Stack.h 操作二叉树使用的栈*/#include "commen.h"int InitStack(LinkStack &head){ head=(StackNode *)malloc(sizeof(StackNode)); if(!head) exit(-1); head->next = NULL; return TRUE;}int原创 2008-06-08 18:36:00 · 680 阅读 · 0 评论 -
遍历二叉树
/*BiTree.h 遍历二叉树*/// 先序遍历二叉树 void Preorder (BiTree T){ if(T) { coutdata Preorder(T->lchild);//遍历左子树 Preorder(T->rchild);//遍历右子树 }}//中序遍历二叉树void Inorder(BiTree T){ if(T原创 2008-06-08 18:24:00 · 782 阅读 · 0 评论 -
二叉树的创建
/*CreateBiTree.h 创建二叉树*/#include "commen.h"/*根据字符串创建一个二叉树,以字符串的形式 “根 左子树 右子树” 定义一棵二叉树*/Status CreateBiTree(BiTree &T) { char ch=getchar(); if(ch== ) T=NULL; else { if(!(T=new BiTN原创 2008-06-08 18:20:00 · 2110 阅读 · 0 评论 -
二叉树的基本操作
/*BiTree.h 二叉树的其他基本操作*///二叉树的深度int Depth_BiTree(BiTree T){ if(T) { int i=Depth_BiTree(T->lchild); int j=Depth_BiTree(T->rchild); if(i>j) return i+1;原创 2008-06-08 18:28:00 · 796 阅读 · 0 评论 -
为实现任务书算法的栈
/*BiTree_TaskStack.h */int InitStack(LinkTaskStack &head){ head=(LinkTaskStack)malloc(sizeof(TNode)); if(!head) exit(-1); head->next = NULL; return TRUE;}int StackEmpty(LinkTaskSta原创 2008-06-08 18:38:00 · 520 阅读 · 0 评论 -
判断字符是否为运算符及运算符优先级
/*extend.h*///判断ch是否为运算符int Comop(char ch){ switch(ch) { case +: case -: case *: case /: case (: case ): case #:return 1; de原创 2008-06-08 18:40:00 · 7988 阅读 · 0 评论