当前位置:网站首页>6-3 find the table length of the linked table
6-3 find the table length of the linked table
2022-07-05 06:36:00 【timingzj】
This question requests to realize a function , Find the length of the linked list .
Function interface definition :
int Length( List L );
among List
The structure is defined as follows :
typedef struct LNode *PtrToLNode;
struct LNode {
ElementType Data;
PtrToLNode Next;
};
typedef PtrToLNode List;
L
Is a given single linked list , function Length
To return the length of the linked list .
Sample referee test procedure :
#include <stdio.h>
#include <stdlib.h>
typedef int ElementType;
typedef struct LNode *PtrToLNode;
struct LNode {
ElementType Data;
PtrToLNode Next;
};
typedef PtrToLNode List;
List Read(); /* Details are not shown here */
int Length( List L );
int main()
{
List L = Read();
printf("%d\n", Length(L));
return 0;
}
/* Your code will be embedded here */
sample input :
1 3 4 5 2 -1
sample output :
5
Code :
int Length( List L )
{
int size = 0;
while(L)
{
L = L->Next;
size++;
}
return size;
}
边栏推荐
猜你喜欢
Chinese remainder theorem acwing 204 Strange way of expressing integers
Utf8 encoding
求组合数 AcWing 887. 求组合数 III
Rehabilitation type force deduction brush question notes D2
[algorithm post interview] interview questions of a small factory
What is socket? Basic introduction to socket
How to make water ripple effect? This wave of water ripple effect pulls full of retro feeling
[2021]IBRNet: Learning Multi-View Image-Based Rendering Qianqian
5.Oracle-表空间
容斥原理 AcWing 890. 能被整除的数
随机推荐
达梦数据库全部
Find the combination number acwing 888 Find the combination number IV
Sum of three terms (construction)
LSA Type Explanation - lsa-5 (type 5 LSA - autonomous system external LSA) and lsa-4 (type 4 LSA - ASBR summary LSA) explanation
Find the combination number acwing 887 Find combination number III
Presentation of attribute value of an item
11-gorm-v2-03-basic query
Game theory acwing 892 Steps Nim game
高斯消元 AcWing 884. 高斯消元解异或线性方程组
NVM Downloading npm version 6.7.0... Error
求组合数 AcWing 887. 求组合数 III
H5 module suspension drag effect
栈 AcWing 3302. 表达式求值
__ builtin_ Popcount() counts the number of 1s, which are commonly used in bit operations
Operator priority, one catch, no doubt
There are three kinds of SQL connections: internal connection, external connection and cross connection
Simple selection sort of selection sort
How to generate an image from text on fly at runtime
LeetCode-54
MQClientException: No route info of this topic: type_ topic