Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
CombileError搞不懂了我用二叉树做的 下面这个函数头似乎有问题,但不知道问题在哪里 编译错误是这样的: C: Main.c(58) : error C2143: syntax error : missing ')' before '&' Main.c(58) : error C2143: syntax error : missing '{' before '&' Main.c(58) : error C2059: syntax error : '&' Main.c(58) : error C2059: syntax error : ')' GCC: Main.c: At top level: Main.c:58: error: syntax error before '&' token Main.c: In function `insert': Main.c:60: error: `root' undeclared (first use in this function) Main.c:60: error: (Each undeclared identifier is reported only once Main.c:60: error: for each function it appears in.) Main.c:64: error: `rec' undeclared (first use in this function) int insert(Tree &root,char *rec) { if(!root) { root=(Node *)malloc(LEN); root->count=1; strcpy(root->item,rec); root->left=root->right= NULL; return 0; } Node *f=NULL,*p=root; while(p) { if(strcmp(p->item,rec)<0) { f=p; p=p->right; }else if(strcmp(p->item,rec)==0) { p->count++; return 1; }else { f=p; p=p->left; } } p=(Node *)malloc(LEN); strcpy(p->item,rec); p->count=1; p->left=p->right=NULL; if(strcmp(f->item,rec)<0) f->right=p; else f->left=p; return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator