|  | 
 
| 
小白刚学..可能错误有点多,求大神解答
x
马上注册,结交更多好友,享用更多功能^_^您需要 登录 才可以下载或查看,没有账号?立即注册    
 错误提示:
 error C2146: syntax error : missing ';' before identifier 'A'
 error C2501: 'St' : missing storage-class or type specifiers
 fatal error C1004: unexpected end of file found
 
 
 求二叉树宽度.exe - 1 error(s), 0 warning(s)
 
 
 #include<stdio.h>
 #include <malloc.h>
 #define maxsize 20
 
 St A[maxsize];
 
 int L=1;//记录层数
 int i=0;
 void width(BTNode *p);
 BTNode *CreateBiTree();
 
 void main()
 {
 int j,k=0;
 int max=0;
 BiTree T;
 T = CreateBiTree();//建立
 width(T);
 
 
 for(j=0;j<=i;j++)
 {
 if(A[j].level==A[j+1].level)
 {
 ++k;
 max=(k>max?k:max);
 }
 else
 k=1;
 }
 printf("%d\n",max);
 
 }
 
 
 typedef struct BTNode{
 int data;
 struct BTNode *lchild,*rchild;
 }BTNode;
 
 //先序建立二叉树
 BTNode *CreateBiTree(){
 char ch;
 BTNode *T;
 scanf("%c",&ch);
 if(ch=='#')T=NULL;
 else{
 T = (BTNode *)malloc(sizeof(BTNode));
 T->data = ch;
 T->lchild = CreateBiTree();
 T->rchild = CreateBiTree();
 }
 return T;//返回根节点
 }
 
 typedef struct
 {
 BTNode *q;
 int level;
 }St;
 
 void width(BTNode *p)
 {
 
 A[i].q=p;
 A[i].level=L;
 ++i;
 ++L;
 width(p->lchild);
 width(p->rchild);
 --L;
 
 }
 
 
 
结构体的声明与定义要放在前面呀~~~ 怎么放到后面去了? | 
 |