#include<stdlib.h>
#include<stdio.h> 【程序编程相关:VB6是基于对象的程序设计工具】 【推荐阅读:.net下软件的自动升级-计划】#include<iostream.h> 【扩展信息:举例讲解returnValue的含义】 #include<string.h> #include<math.h>#define stack_size_normal 100
#define bianliang_max 20 #define str_max 60int zuhe[bianliang_max];//变量的取值组合数组定义;
int n;//变量个数;//根据表达式建立的二叉树的结点定义;
typedef struct btdnode{ char data; struct btdnode *lchild; struct btdnode *rchild; }*bitree;//识别表达式使用的堆栈定义,它存放的都是树的结构;
typedef struct lnode_optr{ struct btdnode **base; //栈中的元素都是树的结点结构; struct btdnode **top; int stacksize; }sqstack; //用于产生变量的各种取值组合;void creatzuhe(int n)
{ int i,num=0,j=0,e; int temp[bianliang_max]; for(i=0;i<n;i++) zuhe[i]=0; while(n) { e=n%2; num++; temp[j++]=e; n=n/2;}
j=j-1; num=n-num; while(j>=0) { e=temp[j--]; zuhe[num++]=e; } }//自底向上地根据运算符地优先级来建立分子树函数;当逻辑表达式读完后-子根zigen就是一棵完整的二叉树
int k=0;//建树的标志,k=1表示第一次建立分子树,要对左右孩子的指针域处理 void create(bitree &zigen,bitree l,bitree r) { zigen->lchild=l; zigen->rchild=r;//分树的链接 if(l&&r) { if(int(l->data)>=65&&int(l->data)<=90) { l->lchild=null; l->rchild=null; } if(int(r->data)>=65&&int(r->data)<=90) { r->lchild=null; r->rchild=null; }}
} //逻辑运算符的优先级判别; char youxianji(char lie,char hang) { ... 下一页