// 统计出单链表L中结点的值等于给定值x的结点数;
typedef struct LNode {
int data;
struct LNode* next;
}LNode,*linklist;
int count_x(linklist &L,int x) {
if (!L) return 0;
LNode* vnode = new LNode;
vnode->next = L;
linklist p = vnode;
int count = 0;
while (p->next != nullptr) {
if (p->next->data == x) count++;
p = p->next;
}
return count;
}
标签:count,LNode,int,练习,next,linklist,vnode From: https://www.cnblogs.com/wanna-be-star/p/17826434.html