试写一算法在带头结点的单链表结构上实现线性表操作Length(L)求表长

2024-12-27 05:28:02
推荐回答(1个)
回答1:

int Length(Node L)
{
int len = 0;
Node *p;
p = L.next();
while(p != NULL) {
len ++;
p = p->next;
}
return len;
}