张吉安马九斤:数据结构:递归求单链表得长度算法

来源:百度文库 编辑:中科新闻网 时间:2024/05/06 11:14:03
一定要是递归得,请各位高手帮帮忙,急!
谢谢
忘了说了,C语言算法

很简单:

int getLen(LIST *p)
{
p?return 1+getLen(p->pNext):return 0;
}

int GetLength(Node *h)
{
if(h->next != NULL)
return 1 + GetLength(h->next);
else
return 1;
}