现在的位置: 首页 > 综合 > 正文

2.13 -实现Locate(L,x)返回x在链表中的位置

2013年11月28日 ⁄ 综合 ⁄ 共 213字 ⁄ 字号 评论关闭
typedef struct node
{
	int data;
	struct node*next;
}Linklist;
typedef struct
{
	int elem[max];
	int length;
}Seqlist;
int Locate(Linklist &L,int x)
{
	int count=0;
	Linklist*p=&L;
	while(p)
	{
		if(p->data==x)
		return count;
		p=p->next;
		count++;
	}
	return 0;
}



抱歉!评论已关闭.