#include <iostream.h>#include <stdio.h>#include <stdlib.h>
typedef char DataType;typedef struct bnode{ DataType data; struct bnode *lchild,*rchild;}Bnode,*BTree;
Bnode *CreatBinTree(BTree t){ char ch; ch=getchar(); if(ch=='0') t=NULL; else {] t=(Bnode*)malloc(sizeof(Bnode)); t->data=ch; t->lchild=CreatBinTree(t->lchild); t->rchild=CreatBinTree(t->rchild); } return t;}
typedef struct node{ DataType data; struct node *next;}Qnode,*PQNode;typedef struct{ PQNode front,rear;}LinkQueue,*PLinkQueue;
PLQueue Init-LinkQueue(){ PLinkQueue Q; Q=(PLinkQueue)malloc(sizeof(LinkQueue)); if(Q) { Q->front=NULL; Q->rear=NULL; } return Q;}
int Empty-LinkQueue(PLinkQueue Q){ if(Q&&->front==NULL&&Q->rear==NULL) return 1; else return 0;}
int In-LinkQueue(PLinkQueue Q,DataType x){ PQNode p; p=(PQNode)malloc(sizeof(Qnode)); if(!p) { printf("内存溢出!\n"); return 0; } p->data=x; p->next=NULL; if(Empty-LinkQueue(Q)) Q->rear=Q->front=p; else { Q->rear->next=p; q->rear=p; } return 1;}int Out-LinkQueue(PLinkQueue Q,DataType *x){ PQNode p; if(Empty-LinkQueue(Q)) { printf("队空!\n"); return 0; } *x=Q->front->data; p=Q->front; Q->front=Q->front->next; free(p); if(!Q->front) Q->rear=NULL; return 1;}
void LayerOrder(BTree t){ printf("%c\n",t->data); PLinkQueue Init-LinkQueue(); int In-LinkQueue(Q,t); while(Empty-LinkQueue(Q)) { Out-LinkQueue(Q,t); if(!t->lchild) { printf("%c\n",t->lchild); In-LinkQueue(); } if(!t->rchild) { printf("%c\n",t->rchild); In-LinkQueue(); } } LayerOrder(t->lchild); LayeerOrder(t->rchild);}
int main(){ printf("请输入序列:"); BTree t,p; p=CreatBinTree(t); LayerOrder(p); return 0;}
编译之后提示的错误如下:--------------------Configuration: BTree1 - Win32 Debug--------------------Compiling...BTree1.cppF:\Seven\DB\DB 习题\Debug\BTree1.cpp(18) : error C2143: syntax error : missing ';' before ']'F:\Seven\DB\DB 习题\Debug\BTree1.cpp(35) : error C2146: syntax error : missing ';' before identifier 'Init'F:\Seven\DB\DB 习题\Debug\BTree1.cpp(35) : error C2501: 'PLQueue' : missing storage-class or type specifiersF:\Seven\DB\DB 习题\Debug\BTree1.cpp(35) : fatal error C1004: unexpected end of file found执行 cl.exe 时出错.BTree1.obj - 1 error(s), 0 warning(s)
谢谢!!!
请帮我修改一个程序,我不知道如何传递参数,我不会修改编译之后提示的错误
答案:1 悬赏:40 手机版
解决时间 2021-05-05 12:30
- 提问者网友:無理詩人
- 2021-05-04 20:53
最佳答案
- 五星知识达人网友:渊鱼
- 2021-05-04 21:52
你的代码都堆一块去了,很难看清楚,别人就懒得仔细看。
你还是把它整理为好看的格式再贴一次。
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯