当前位置:网站首页>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;
}
边栏推荐
- Vant Weapp SwipeCell设置多个按钮
- How to set the drop-down arrow in the spinner- How to set dropdown arrow in spinner?
- Redis-01. First meet redis
- [2020]GRAF: Generative Radiance Fields for 3D-Aware Image Synthesis
- 5. Oracle TABLESPACE
- 20220213-CTF MISC-a_ good_ Idea (use of stegsolve tool) -2017_ Dating_ in_ Singapore
- Vant Weapp SwipeCell設置多個按鈕
- MPLS experiment
- Install opencv -- CONDA to establish a virtual environment and add the kernel of this environment in jupyter
- How to generate an image from text on fly at runtime
猜你喜欢
AE tutorial - path growth animation
how to understand the “model independent.“
Speedtree01 generator properties
LSA Type Explanation - lsa-1 [type 1 LSA - router LSA] detailed explanation
International Open Source firmware Foundation (osff) organization
Paper reading report
MPLS experiment
Rehabilitation type force deduction brush question notes D1
7. Oracle table structure
confidential! Netease employee data analysis internal training course, white whoring! (attach a data package worth 399 yuan)
随机推荐
2048 project realization
Paper reading report
The route of wechat applet jumps again without triggering onload
求组合数 AcWing 887. 求组合数 III
[wustctf2020] plain_ WP
博弈论 AcWing 893. 集合-Nim游戏
Some classic recursion problems
H5内嵌App适配暗黑模式
容斥原理 AcWing 890. 能被整除的数
What is socket? Basic introduction to socket
RecyclerView的应用
11-gorm-v2-02-create data
Day 2 document
P2575 master fight
How to understand the definition of sequence limit?
There are three kinds of SQL connections: internal connection, external connection and cross connection
Single chip computer engineering experience - layered idea
Vant weapp swippecell set multiple buttons
our solution
Find the combination number acwing 887 Find combination number III