Table 6-3 seeking long chain table (10 minutes)

Topic Address: https://pintia.cn/problem-sets/15/problems/726

Calculating the length of the linked list, an empty list note Laid sentence case

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

 

Guess you like

Origin www.cnblogs.com/mile-star/p/11449353.html