Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

CombileError搞不懂了

Posted by cm8421 at 2008-04-23 00:26:52 on Problem 1002
我用二叉树做的
下面这个函数头似乎有问题,但不知道问题在哪里
编译错误是这样的:
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator