码迷,mamicode.com
首页 > 其他好文 > 详细

6-3 求链式表的表长 (10 分)

时间:2019-09-02 22:16:49      阅读:181      评论:0      收藏:0      [点我收藏+]

标签:span   src   out   color   式表   hid   return   click   ems   

题目地址:https://pintia.cn/problem-sets/15/problems/726

计算链表长度,注意特判空链表的情况

技术图片
int Length(List L)
{
    if(!L) return 0;//特判空链表
    int len = 1;cout<<L->Data<<endl;
    while(L->Next != NULL) {
        len++;

        L = L->Next;
    }
    return len;
}
View Code

 

6-3 求链式表的表长 (10 分)

标签:span   src   out   color   式表   hid   return   click   ems   

原文地址:https://www.cnblogs.com/mile-star/p/11449353.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!