当前位置:网站首页>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;
}
边栏推荐
- 2. Addition and management of Oracle data files
- 2022 winter vacation training game 5
- [Gaode map POI stepping pit] amap Placesearch cannot be used
- 11-gorm-v2-02-create data
- Stack acwing 3302 Expression evaluation
- ollvm编译出现的问题纪录
- 将webApp或者H5页面打包成App
- The “mode“ argument must be integer. Received an instance of Object
- Series of how MySQL works (VIII) 14 figures explain the atomicity of MySQL transactions and the principle of undo logging
- vsCode创建自己的代码模板
猜你喜欢
[QT] QT multithreading development qthread
Configuration method and configuration file of SolidWorks GB profile library
求组合数 AcWing 889. 满足条件的01序列
how to understand the “model independent.“
What is linting
Suppose a bank's ATM machine, which allows users to deposit and withdraw money. Now there is 200 yuan in an account, and both user a and user B have the right to deposit and withdraw money from this a
AE tutorial - path growth animation
Redis-01. First meet redis
Install opencv -- CONDA to establish a virtual environment and add the kernel of this environment in jupyter
VLAN experiment
随机推荐
2022/6/29-日报
Single chip computer engineering experience - layered idea
Huawei bracelet, how to add medicine reminder?
Client use of Argo CD installation
[Chongqing Guangdong education] 1185t administrative leadership reference test of National Open University in autumn 2018
Vant weave swipecell sets multiple buttons
Vscode creates its own code template
Redis-02. Redis command
Record of problems in ollvm compilation
微信小程序路由再次跳转不触发onload
Game theory acwing 892 Steps Nim game
AE tutorial - path growth animation
H5 embedded app adapts to dark mode
RecyclerView的应用
[learning] database: MySQL query conditions have functions that lead to index failure. Establish functional indexes
2. Addition and management of Oracle data files
Gauss Cancellation acwing 884. Solution d'un système d'équations Xor linéaires par élimination gaussienne
2048项目实现
H5内嵌App适配暗黑模式
How to correctly ask questions in CSDN Q & A