(1)设计一算法,计算单链表中数据域为x的节点个数 C语言数据结构 int CountX(LNode *head,ElemType x);

如题所述

你好!
请采纳


int CountX(LNode * head,ElemType x)
{
    LNode *p=head;
    int count=0;
    while(p)
    {
        if(p->data==x)
            count++;
        p=p->next;
    }
    return count;
}

温馨提示:答案为网友推荐,仅供参考
相似回答