报错显示的是符号错误,缺少分号,但是明明有分号呀,到底错在哪里
程序代码:
#include<stdio.h> #include<stdlib.h> #include<malloc.h> typedef struct tree { int date; struct tree *lchild; struct tree *rchild; }tree,*T;//定义树的数据结构; T paixu_tree(T t,int e) { T t1,p,q; p=t; t1=(T)malloc(sizeof(tree)); t1->date=e;t1->lchild=NULL;t1->rchild=NULL; if(p==NULL) t=p=t1; else { while(p!=NULL) { if(p->date>=t1->date) { q=p; p=p->lchild; } else(p->date<t1->date) { q=p;//error C2143: syntax error : missing ';' before '{' p=p->rchild; } }//q用来记录所插入节点的双亲结点; if(q->date>=t1->date) q->lchild=t1; else(q->date<t1->date) q->rchild=t1;//error C2146: syntax error : missing ';' before identifier 'q' } return t; }//二叉排序树 void main() { T t;int e,i; t=NULL; for(i=0;i<10;i++) { scanf("%d",&e); getchar(); t=paixu_tree(t,e); } }