长沙永拓会计师事务所:too many types in declaration怎么解决

来源:百度文库 编辑:高校问答 时间:2024/04/30 14:04:03
#include "stdio.h"
#include "stdlib.h"
#define ELEMTP int
struct node
{ int data;
struct node *lc,*rc;
}
struct node *root;
int m=0;
main()
{ int cord;
struct node *creat();
void preorderz(struct node *t);
void inorder(struct node *t);
void postorder(struct node *t);
do { printf("\n \n");
printf(" 1 \n");
printf(" 2 \n");
printf(" 3 \n");
printf(" 4 \n");
printf(" 5 \n");
printf("---------------------------------------------- \n");
printf("(1,2,3,4)");
scanf("%d",&cord);
switch(cord)
{ case 1:{ root=creat();
printf("\n");
printf("\n");
}break;
case 2:{ preorderz(root);
printf("\n");
printf("\n");
}break;
case 3: { inorder(root);
printf("\n");
}break;
case 4: { postorder(root);
printf("\n \n");
printf("m=%3d\n",m);
}
case 5: {printf("\n");
exit(0);
}
}
}while(cord<=5);
}
struct node *creat()
{ struct node *t,*q,*s[30];
int i,j,x;
printf("i,x=");scanf("%d%d",&i,&x);
while((i!=0)&&(x!=0))
{ q=(struct node *)malloc(sizeof(struct node ));
q->data=x;q->lc=NULL;q->rc=NULL;
s[i]=q;
if(i==1)t=q;
else {j=i/2;
if((i%2)==0) s[j]->lc=q;else s[j]->rc=q;
}
printf("i,x=");scanf("%d%d",&i,&x);
}
return(t);
}
void preorderz(struct node *p)
{ struct node *q,*s[30];
int top,bool;
q=p;top=0;
bool=1;
do{while(q!=NULL){printf("%6d",q->data);
top++;s[top]=q;q=q->rc;}
if(top==0)bool=0;
else{ q=s[top];top--;q=q->rc;}
}while(bool);
printf("\n");
}
void inorder(struct node *p)
{ if(p!=NULL) { inorder(p->lc);
printf("%6d",p->data);
inorder(p->rc);
}
}
void postorder(struct node *p)
{ if(p!=NULL) { postorder(p->lc);
postorder(p->rc);
printf("%6d",p->data);
if(p->lc==NULL&&p->rc==NULL)m++;
}
}
编译后提示第八行struct node *root有错误:too many types in declaration帮我解决一下,谢谢!!

先把 struct 去掉试试