当前位置:首页 » 编程软件 » 编译原理胡元义第三版答案

编译原理胡元义第三版答案

发布时间: 2023-01-15 22:17:25

‘壹’ 急急急,编译原理

using namespace std;

struct BiNode
{
char data;
BiNode *lchild, *rchild;
};
typedef BiNode *BiTree;

int CreateBiTree(BiTree &T, const char *s1, const char *s2, int len)
{
if (len<=0)
{
T = NULL;
return 1;
}
else
{
T = new BiNode;
T->data = *s1;
int i;
for ( i=0; i<len; i++) if (s2[i]==*s1) break;
CreateBiTree(T->lchild, s1+1, s2, i);
CreateBiTree(T->rchild, s1+i+1, s2+i+1, len-(i+1));
}
return 1;
}

int DestroyBiTree(BiTree &T)
{
if (T==NULL) return 1;
DestroyBiTree(T->lchild);
DestroyBiTree(T->rchild);
delete T;
T = NULL;
return 1;
}

int ATraverse(BiTree &T)
{
if (T==NULL) return 1;
ATraverse(T->lchild);
ATraverse(T->rchild);
cout<<T->data;
return 1;
}

main()
{
char a[2000],b[2000];
while(cin>>a>>b)
{
BiTree T;
int count=0;
int n;
for(n=0;a[n]!='\0';n++);
CreateBiTree(T,a,b,n);
ATraverse(T);
cout<<" ";

cout<<endl;
DestroyBiTree(T);

‘贰’ 编译原理教程(第二版)》(胡元义主编,西安电子科技大学出版社出版)课后习题答案

http://cache..com/c?m=13d3c3&p=9f769a448faf09ea08e2977e7f00&user=

热点内容
java返回this 发布:2025-10-20 08:28:16 浏览:648
制作脚本网站 发布:2025-10-20 08:17:34 浏览:939
python中的init方法 发布:2025-10-20 08:17:33 浏览:634
图案密码什么意思 发布:2025-10-20 08:16:56 浏览:823
怎么清理微信视频缓存 发布:2025-10-20 08:12:37 浏览:734
c语言编译器怎么看执行过程 发布:2025-10-20 08:00:32 浏览:1069
邮箱如何填写发信服务器 发布:2025-10-20 07:45:27 浏览:302
shell脚本入门案例 发布:2025-10-20 07:44:45 浏览:163
怎么上传照片浏览上传 发布:2025-10-20 07:44:03 浏览:855
python股票数据获取 发布:2025-10-20 07:39:44 浏览:765