若x和y是两个用单链表存储的串,写一个算法找出x中第一个不在y中出现的字符

typedef struct LNode{char data;struct LNode *next;}*Linklist;

char findfirst(Linklist *x,Linklist *y)
{
	Linklist *p;
	char c;
	p=x;
	if(x==NULL)
	{
		printf("x为空\n");
	}else{
		while(found(p->data,y))
		{
			p=p->next;
		}
		c=p->data;
	}
	return c;
}

int found(char ch,Linklist *head)
{
	while(head!=NULL && head->data!=ch)
	{
		head=head->next;
	}
	if(head==NULL)
	{
		return 0;
	}else{
		return 1;
	}
}
发布了67 篇原创文章 · 获赞 25 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/qq_41104871/article/details/101191911
今日推荐