当前位置:网站首页>6-3 find the table length of the linked table
6-3 find the table length of the linked table
2022-07-07 22:45:00 【Qingshan's green shirt】
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 */
Ideas
Create a pointer p, Used to traverse a linked list . Create a counter , For statistical length .
Specific code implementation
int Length( List L )
{
List p; // The pointer p, Notice that it's not List*!!!!!!!!
p = L;
int j = 0;
while( p)
{
j++;
p = p->Next;
}
return j;
}
Some of my questions
1. At first, the compilation error is because it is always written List *p!! Still don't understand structure and typedef Usage of !
2021.10.05
21:22
边栏推荐
- The whole network "chases" Zhong Xuegao
- Two methods of calling WCF service by C #
- Yarn cannot view the historical task log of yarn after enabling ACL user authentication. Solution
- IP网络主动测评系统——X-Vision
- What is the difference between the three values of null Nan undefined in JS
- Typeorm automatically generates entity classes
- Revit secondary development - link file collision detection
- VTOL in Px4_ att_ Control source code analysis [supplement]
- How to close eslint related rules
- Ren Qian code compilation error modification
猜你喜欢
【Azure微服务 Service Fabric 】在SF节点中开启Performance Monitor及设置抓取进程的方式
Application practice | the efficiency of the data warehouse system has been comprehensively improved! Data warehouse construction based on Apache Doris in Tongcheng digital Department
Record a garbled code during servlet learning
Cannot find module 'xxx' or its corresponding type declaration
Paint basic graphics with custompaint
VTOL in Px4_ att_ Control source code analysis [supplement]
100million single men and women "online dating", supporting 13billion IPOs
UWA Q & a collection
0-5VAC转4-20mA交流电流隔离变送器/转换模块
Firefox browser installation impression notes clipping
随机推荐
Unity technical notes (II) basic functions of scriptableobject
Revit secondary development - intercept project error / warning pop-up
C # realizes the communication between Modbus protocol and PLC
SAR image quality evaluation
What does it mean to prefix a string with F?
「开源摘星计划」Loki实现Harbor日志的高效管理
微服务远程Debug,Nocalhost + Rainbond微服务开发第二弹
0-5vac to 4-20mA AC current isolated transmitter / conversion module
OpenGL configuration vs2019
C # Development -- pit encountered in JS intermodulation
Customer case | China law network, through observing the cloud, greatly shortens the time of fault location
Time convolution Network + soft threshold + attention mechanism to realize residual life prediction of mechanical equipment
[interview arrangement] 0211 game engine server
Unity local coordinates and world coordinates
微服務遠程Debug,Nocalhost + Rainbond微服務開發第二彈
苹果在iOS 16中通过'虚拟卡'安全功能进一步进军金融领域
Take full control! Create a "leading cockpit" for smart city construction
UWA问答精选
Debezium系列之: 支持在 KILL 命令中使用变量
Redis official ORM framework is more elegant than redistemplate