本文对链表的常见问题进行总结和归纳:
定义链表的数据结构如下:
struct ListNode{ int value; ListNode *next; }
unsigned int GetListLength(ListNode *pHead) { if (pHead == NULL) { //判断是否为空链表 return 0; } unsigned int ListLength = 0; ListNode * pCurrent = pHead; while (pCurrent) { ListLength++; pCurrent = pCurrent->next; } return ListLength; }
原文:http://www.cnblogs.com/smallrookie/p/6476776.html