int SearchList(struct MyList *L, char variable, char temp_find) { struct MyList *temp = L->next; printf("查找中\n"); while (temp != NULL) { if (!strcmp(variable, "编号")) if (!strcmp(temp->thing.num, temp_find)) { printf(" 班费收支编号为: %s\n", temp->thing.num); printf(" 收入和还是支出: %s\n", temp->thing.into); printf(" 经办人是: %s\n", temp->thing.name); printf(" 收费原因为: %s\n", temp->thing.cause); printf(" 收费金额为: %s\n", temp->thing.money); printf(" 收费的总人数为: %s\n", temp->thing.people); printf(" 收费的日期为: %s\n", temp->thing.time); printf("\n"); }

时间: 2024-04-25 13:26:51 浏览: 12
这段代码定义了一个名为SearchList的函数,其作用是在链表L中查找特定字段为temp_find的节点,并打印该节点的所有数据。具体来说: - 函数接受三个参数:指向链表头的指针L、要查找的字段名称variable和要查找的字段值temp_find。 - 函数返回值为整型,表示查找到的节点个数。 - 首先定义了一个指针变量temp,指向链表头的下一个节点。 - 执行printf语句,输出"查找中"的提示信息。 - 进入while循环,只要temp不为NULL,就执行循环体中的语句。 - 在循环体中,如果要查找的字段为"编号",且当前节点的编号与要查找的编号相同,则打印该节点的所有数据。 - 最后将temp指向下一个节点,继续遍历,直到temp为NULL,退出循环。 - 返回查找到的节点个数。
相关问题

struct MyList { fee thing; struct MyList *next; }; int InitList(struct MyList *L); int InsertList(struct MyList *L, fee e); void FinderList(struct MyList *L); int SearchList(struct MyList *L, char variable, char temp_find); int ReplacedList(struct MyList *L, int i, char* num, char* into, char* name, char* cause, char* money, char* people, char* time); int DeleteList(struct MyList *L, int i); int ClearList(struct MyList *L);

这段代码定义了一个链表结构体MyList,包含了两个成员:thing和next。其中thing是一个结构体变量,用来存储班费信息,next是一个指向下一个链表结构体的指针。除此之外,代码中还定义了若干个函数,包括: 1. InitList:初始化链表,将链表中的所有元素清空。 2. InsertList:在链表中插入一个元素。 3. FinderList:查找链表中的元素。 4. SearchList:根据班费信息的某个字段,在链表中查找符合条件的元素。 5. ReplacedList:替换链表中的某个元素。 6. DeleteList:删除链表中的某个元素。 7. ClearList:清空整个链表。 这些函数实现了链表的基本操作,可以用来对班费信息进行增删改查等操作。需要注意的是,代码中的函数参数有些简略,具体实现需要参考函数体中的代码。

void push_tail(struct LinkList* list, struct Node* temp) { temp->pro = list->head; temp->next = list->tail; list->tail->pro = temp; list->head->next = temp; list->head = temp; }优化一下这个代码,使用双向链表的头插法

void push_head(struct LinkList* list, struct Node* temp) { temp->next = list->head->next; temp->pro = list->head; list->head->next->pro = temp; list->head->next = temp; list->tail = (list->tail == list->head) ? temp : list->tail; } 这是使用双向链表头插法的代码。需要注意的是,当链表为空时,头尾节点都需要指向新插入的节点。因此,需要判断一下链表是否为空。

相关推荐

#define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<windows.h> #include<string.h> #include<stdlib.h> #include<math.h> #include<malloc.h> typedef struct character_name { char name[100]; struct character_name* next; }char_name; typedef struct character_title { char title[100]; struct character_title* next; }char_title; typedef struct character_identity { char identity[100]; struct character_identity* next; }char_iden; typedef struct character_attribute { int strength; struct character_attribute* next; }char_att; typedef struct character_information { char_name* _name; char_title* _title; char_iden* _iden; char_att* _att; struct character_information* next; }char_inf; char_inf* initialization() { char_inf* node = (char_inf*)malloc(sizeof(char_inf)); node->_name = (char_name*)malloc(sizeof(char_name)); node->_title = (char_title*)malloc(sizeof(char_title)); node->_iden = (char_iden*)malloc(sizeof(char_iden)); node->_att = (char_att*)malloc(sizeof(char_att)); return node; } char_inf* ceshi, * current, * end; char_name* name_current, * name_end; char_title* title_current, * title_end; char_iden* iden_current, * iden_end; char_att* att_current, att_end; int main() { ceshi = initialization(); name_current = (char_name*)malloc(sizeof(char_name)); name_current = ceshi->_name; strcpy(name_current->name, "ceshi_1_1"); name_current->next = (char_name*)malloc(sizeof(char_name)); name_current = name_current->next; strcpy(name_current->name, "ceshi_1_2"); strcpy(ceshi->_title->title, "ceshi_2"); strcpy(ceshi->_iden->identity, "ceshi_3"); ceshi->_att->strength = 4; name_current = ceshi->_name; while (name_current->next != NULL) { printf("%s\n", name_current->name); name_current = name_current->next; } printf("%s\n%s\n%d\n", ceshi->_title->title, ceshi->_iden->identity, ceshi->_att->strength); return 0; } 为什么提示我访问权限报错

#define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<windows.h> #include<string.h> #include<stdlib.h> #include<math.h> typedef struct character_name { char name[100]; struct character_name* next; }char_name; typedef struct character_title { char title[100]; struct character_title* next; }char_title; typedef struct character_identity { char identity[100]; struct character_identity* next; }char_iden; typedef struct character_profession { char profession[100]; int level; struct character_profession* next; }char_pro; typedef struct character_ability { char ability[100]; char explain[1000]; struct character_ability* next; }char_abi; typedef struct character_race { char race[100]; struct character_race* next; }char_race; typedef struct character_information { int age; int gender; char_name* _name; char_title* _title; char_iden* _iden; char_pro* _pro; char_abi* _abi; char_race* _race; struct character_information* next; }char_inf; char_inf* initialization() { char_inf* node = (char_inf*)malloc(sizeof(char_inf)); node->_name = (char_name*)malloc(sizeof(char_name)); node->_title = (char_title*)malloc(sizeof(char_title)); node->_iden = (char_iden*)malloc(sizeof(char_iden)); node->_pro = (char_pro*)malloc(sizeof(char_pro)); node->_abi = (char_abi*)malloc(sizeof(char_abi)); node->_race = (char_race*)malloc(sizeof(char_race)); return node; } char_inf* ceshi, * current, * end; char_name* name_current, * name_end; char_title* title_current, * title_end; char_iden* iden_current, * iden_end; char_pro* pro_current, * pro_end; char_abi* abi_current, * abi_end; char_race* race_current, * race_end; int main() { ceshi = initialization(); ceshi->age = 666; ceshi->gender = 1; name_current = ceshi->_name; strcpy(name_current->name, "ceshi_name_1"); name_current->next = (char_name*)malloc(sizeof(char_name)); name_current = name_current->next; name_current->next = NULL; strcpy(name_current->name, "ceshi_name_2"); strcpy(ceshi->_title->title, "ceshi_title"); strcpy(ceshi->_iden->identity, "ceshi_identity"); strcpy(ceshi->_pro->profession, "ceshi_profession"); strcpy(ceshi->_abi->ability, "ceshi_ability"); strcpy(ceshi->_abi->explain, "ceshi_ability_explain"); strcpy(ceshi->_race->race, "ceshi_race"); ceshi->_pro->level = 666; name_current = ceshi->_name; printf(" Age: %d\n", ceshi->age); printf(" Gender: "); if (ceshi->gender == 0) printf("woman\n"); else printf("male\n"); while (name_current != NULL) { printf(" Name: %s\n", name_current->name); name_current = name_current->next; } printf(" Title: %s\n Identity: %s\n Profession: %d\n Ability: %s\n Ability_Explain: %s\n Race: %s\n", ceshi->_title->title, ceshi->_iden->identity,ceshi->_pro->level,ceshi->_abi->ability,ceshi->_abi->explain,ceshi->_race->race); return 0; } 怎样可以消除取消对NULL指针的引用这个警告

最新推荐

recommend-type

基于网络的入侵检测系统源码+数据集+详细文档(高分毕业设计).zip

基于网络的入侵检测系统源码+数据集+详细文档(高分毕业设计).zip个人经导师指导并认可通过的高分毕业设计项目,评审分98分。主要针对计算机相关专业的正在做毕设的学生和需要项目实战练习的学习者,也可作为课程设计、期末大作业。 基于网络的入侵检测系统源码+数据集+详细文档(高分毕业设计).zip基于网络的入侵检测系统源码+数据集+详细文档(高分毕业设计).zip基于网络的入侵检测系统源码+数据集+详细文档(高分毕业设计).zip基于网络的入侵检测系统源码+数据集+详细文档(高分毕业设计).zip基于网络的入侵检测系统源码+数据集+详细文档(高分毕业设计).zip基于网络的入侵检测系统源码+数据集+详细文档(高分毕业设计).zip基于网络的入侵检测系统源码+数据集+详细文档(高分毕业设计).zip基于网络的入侵检测系统源码+数据集+详细文档(高分毕业设计).zip基于网络的入侵检测系统源码+数据集+详细文档(高分毕业设计).zip基于网络的入侵检测系统源码+数据集+详细文档(高分毕业设计).zip基于网络的入侵检测系统源码+数据集+详细文档(高分毕业设计).zip基于网络的入侵检测系统
recommend-type

本户型为2层独栋别墅D026-两层-13.14&12.84米-施工图.dwg

本户型为2层独栋别墅,建筑面积239平方米,占地面积155平米;一层建筑面积155平方米,设有客厅、餐厅、厨房、卧室3间、卫生间1间、杂物间;二层建筑面积84平方米,设有卧室2间、卫生间1间、储藏间、1个大露台。 本户型外观造型别致大方,采光通风良好,色彩明快,整体平面布局紧凑、功能分区合理,房间尺度设计适宜,豪华大气,富有时代气息。
recommend-type

Java_带有可选web的开源命令行RatioMaster.zip

Java_带有可选web的开源命令行RatioMaster
recommend-type

基于MATLAB实现的OFDM经典同步算法之一Park算法仿真,附带Park算法经典文献+代码文档+使用说明文档.rar

CSDN IT狂飙上传的代码均可运行,功能ok的情况下才上传的,直接替换数据即可使用,小白也能轻松上手 【资源说明】 基于MATLAB实现的OFDM经典同步算法之一Park算法仿真,附带Park算法经典文献+代码文档+使用说明文档.rar 1、代码压缩包内容 主函数:main.m; 调用函数:其他m文件;无需运行 运行结果效果图; 2、代码运行版本 Matlab 2020b;若运行有误,根据提示GPT修改;若不会,私信博主(问题描述要详细); 3、运行操作步骤 步骤一:将所有文件放到Matlab的当前文件夹中; 步骤二:双击打开main.m文件; 步骤三:点击运行,等程序运行完得到结果; 4、仿真咨询 如需其他服务,可后台私信博主; 4.1 期刊或参考文献复现 4.2 Matlab程序定制 4.3 科研合作 功率谱估计: 故障诊断分析: 雷达通信:雷达LFM、MIMO、成像、定位、干扰、检测、信号分析、脉冲压缩 滤波估计:SOC估计 目标定位:WSN定位、滤波跟踪、目标定位 生物电信号:肌电信号EMG、脑电信号EEG、心电信号ECG 通信系统:DOA估计、编码译码、变分模态分解、管道泄漏、滤波器、数字信号处理+传输+分析+去噪、数字信号调制、误码率、信号估计、DTMF、信号检测识别融合、LEACH协议、信号检测、水声通信 5、欢迎下载,沟通交流,互相学习,共同进步!
recommend-type

基于MATLAB实现的对机械振动信号用三维能量谱进行分析+使用说明文档.rar

CSDN IT狂飙上传的代码均可运行,功能ok的情况下才上传的,直接替换数据即可使用,小白也能轻松上手 【资源说明】 基于MATLAB实现的对机械振动信号用三维能量谱进行分析+使用说明文档.rar 1、代码压缩包内容 主函数:main.m; 调用函数:其他m文件;无需运行 运行结果效果图; 2、代码运行版本 Matlab 2020b;若运行有误,根据提示GPT修改;若不会,私信博主(问题描述要详细); 3、运行操作步骤 步骤一:将所有文件放到Matlab的当前文件夹中; 步骤二:双击打开main.m文件; 步骤三:点击运行,等程序运行完得到结果; 4、仿真咨询 如需其他服务,可后台私信博主; 4.1 期刊或参考文献复现 4.2 Matlab程序定制 4.3 科研合作 功率谱估计: 故障诊断分析: 雷达通信:雷达LFM、MIMO、成像、定位、干扰、检测、信号分析、脉冲压缩 滤波估计:SOC估计 目标定位:WSN定位、滤波跟踪、目标定位 生物电信号:肌电信号EMG、脑电信号EEG、心电信号ECG 通信系统:DOA估计、编码译码、变分模态分解、管道泄漏、滤波器、数字信号处理+传输+分析+去噪、数字信号调制、误码率、信号估计、DTMF、信号检测识别融合、LEACH协议、信号检测、水声通信 5、欢迎下载,沟通交流,互相学习,共同进步!
recommend-type

zigbee-cluster-library-specification

最新的zigbee-cluster-library-specification说明文档。
recommend-type

管理建模和仿真的文件

管理Boualem Benatallah引用此版本:布阿利姆·贝纳塔拉。管理建模和仿真。约瑟夫-傅立叶大学-格勒诺布尔第一大学,1996年。法语。NNT:电话:00345357HAL ID:电话:00345357https://theses.hal.science/tel-003453572008年12月9日提交HAL是一个多学科的开放存取档案馆,用于存放和传播科学研究论文,无论它们是否被公开。论文可以来自法国或国外的教学和研究机构,也可以来自公共或私人研究中心。L’archive ouverte pluridisciplinaire
recommend-type

【实战演练】MATLAB用遗传算法改进粒子群GA-PSO算法

![MATLAB智能算法合集](https://static.fuxi.netease.com/fuxi-official/web/20221101/83f465753fd49c41536a5640367d4340.jpg) # 2.1 遗传算法的原理和实现 遗传算法(GA)是一种受生物进化过程启发的优化算法。它通过模拟自然选择和遗传机制来搜索最优解。 **2.1.1 遗传算法的编码和解码** 编码是将问题空间中的解表示为二进制字符串或其他数据结构的过程。解码是将编码的解转换为问题空间中的实际解的过程。常见的编码方法包括二进制编码、实数编码和树形编码。 **2.1.2 遗传算法的交叉和
recommend-type

openstack的20种接口有哪些

以下是OpenStack的20种API接口: 1. Identity (Keystone) API 2. Compute (Nova) API 3. Networking (Neutron) API 4. Block Storage (Cinder) API 5. Object Storage (Swift) API 6. Image (Glance) API 7. Telemetry (Ceilometer) API 8. Orchestration (Heat) API 9. Database (Trove) API 10. Bare Metal (Ironic) API 11. DNS
recommend-type

JSBSim Reference Manual

JSBSim参考手册,其中包含JSBSim简介,JSBSim配置文件xml的编写语法,编程手册以及一些应用实例等。其中有部分内容还没有写完,估计有生之年很难看到完整版了,但是内容还是很有参考价值的。