【2 线性表】统计单链表中x值的结点数。

int Countx(Linklist L,int x){
	LNode *p=L->next;
	int count=0;
	if(p==NULL)
		return 0;
	while(p){
		if(p->data==x)
			count++;
		p=p->next;
	}
	return count;
}

你可能感兴趣的:(2,线性表,c++,数据结构,leetcode)