C语言的链表的相关操作
本变博客源于自己想复习一下C语言,所以便自己动手复习了一下链表的相关操作。做个人记录使用。
main.c
#include <stdio.h>
#include "list.h"int main()
{student *a;printf("hello world\n") ;printf("----初始化列表----------\n");a=init();printf("----创建列表----------\n");create_front_list(a,3);printf("list的个数为:count= %d\n",count);printf("----读取列表3位置上数据----------\n");read_any_list(a,3);printf("------------读取全部数据------------------\n");read_all_list(a);printf("----------插入列表,插入到位4的后面--------------------\n");insert_behind_list(a ,4);printf("----------插完后的列表数据---------\n");read_all_list(a);printf("------------删除列表指定位置的数据-------------------\n");delete_list(a,2);printf("-------------删除后列表的数据------------------\n");read_all_list(a);return 0;
}
list.c
#include<stdio.h>
#include <stdlib.h>
#include "list.h"
int count = 0;
student *init()
{//chuangjian节点student * head=(struct student *)malloc(sizeof(student));if(head==NULL){printf("n=malloc failed \n");return NULL;}head->num=0;head->score=99.2;head->next=NULL;count++;return head;}//链表的建立
void create_front_list(student *head,int n)
{ int i;student * last;student * s;last=head;s=head;printf("请你输入%d个整数\n",n);for(i=0;i<n;i++){printf("begin to input\n");s->next=(struct student *)malloc(sizeof(student));last=s->next;s=last;scanf("%d,%f",&(s->num),&(s->score));printf("end to input\n");count++;}s->next=NULL;last=NULL;s=NULL;return ;
}//链表的读取操作
void read_all_list(student * head)
{int i;printf("total data in list is \n");student *re=head;if(head==NULL){printf("NO data\n");return ;}else{for(i=0;i<count;i++){printf("num = %d score= %f \n",re->num, re->score);re=re->next;}}}//读取其中指定第几个节点的数值
void read_any_list(student * head,int n)
{ int i=1;student *re=head;printf("That you want to read list sequence is %d\n",n);if(n>count){printf("The number you have input exceeds the max length of this list \n ");return ;}else{while(true){re=re->next;i++;if(i==n){printf("the number has been find ,data as follow \n");printf("num= %d, score= %f\n",re->num,re->score);break;}}return ;}}//链表的插入//由于是单链表所以我这里只使用尾部
void insert_behind_list(student * head ,int n)
{printf("insert behind list \n\n");int i;student * s=head;if(n>count){//表名插入的位置已经查过了节点长度printf("you has exceed this max length\n");return ;}else{ //开辟一个新的节点student * last=(struct student *)malloc(sizeof(student));printf("please input your inserted data \n");scanf("%d,%f",&(last->num),&(last->score));for(i=1;i<n;i++){s=s->next;//借助一个指针指向你想插入的节点前面}last->next=s->next;s->next=last;last=NULL;printf("---------end of insert data--------\n");count++;}}//链表的删除
void delete_list(student * head,int n)
{int i;student * s=head;student * q=head->next;printf("the number do you want to delete is number %d",n);if(n>count){printf("there are no data \n");}else{for(i=1;i<n;i++){s=s->next;q=q->next;}printf("你想删除的数据是:%d,%f",q->num,q->score);s->next=q->next;free(q);count--;//记录节点的个数的}}
list.h
#define true 1
#define flase 0typedef struct student{int num;float score;struct student *next ;}student;
extern int count;
student *init();
void create_front_list(student *head,int n);
void read_all_list(student * head);
void read_any_list(student * head,int n);
void insert_behind_list(student * head ,int n);
void delete_list(student * head,int n);
备注:每次更改操作后必须使用count–,否则内存就会出现泄漏。
hello world
----初始化列表----------
----创建列表----------
请你输入3个整数
begin to input
1,1
end to input
begin to input
2,2
end to input
begin to input
3,3
end to input
list的个数为:count= 4
----读取列表3位置上数据----------
That you want to read list sequence is 3
the number has been find ,data as follow
num= 2, score= 2.000000
------------读取全部数据------------------
total data in list is
num = 0 score= 99.199997
num = 1 score= 1.000000
num = 2 score= 2.000000
num = 3 score= 3.000000
----------插入列表,插入到位4的后面--------------------
insert behind list
please input your inserted data
4,4
---------end of insert data--------
----------插完后的列表数据---------
total data in list is
num = 0 score= 99.199997
num = 1 score= 1.000000
num = 2 score= 2.000000
num = 3 score= 3.000000
num = 4 score= 4.000000
------------删除列表指定位置的数据-------------------
the number do you want to delete is number 2你想删除的数据是:2,2.000000-------------删除后列表的数据------------------
total data in list is
num = 0 score= 99.199997
num = 1 score= 1.000000
num = 3 score= 3.000000
num = 4 score= 4.000000
Process returned 0 (0x0) execution time : 27.276 s
Press any key to continue.

相关文章:
C语言的链表的相关操作
本变博客源于自己想复习一下C语言,所以便自己动手复习了一下链表的相关操作。做个人记录使用。 main.c #include <stdio.h> #include "list.h"int main() {student *a;printf("hello world\n") ;printf("----初始化列表----------\…...
Python3中typing模块
Python类型注解是Python 3.5版本之后引入的新特性,它可以让开发者在函数、变量等声明时为其指定类型。typing模型能够声明类型,防止运行时出现参数和返回值类型不符合的问题。 ### 1. 基本类型注解 def hello(name: str) -> str:return (Hello, na…...
C语言自动抓取淘宝商品详情网页数据,实现轻松高效爬虫
你是否曾经遇到过需要大量获取网页上的数据,但手动复制粘贴又太过费时费力?那么这篇文章就是为你而写。今天我们将会详细讨论如何使用C语言实现自动抓取网页上的数据。本文将会从以下8个方面进行逐步分析讨论。 1. HTTP协议的基本原理 在开始之前&…...
数据结构---跳表
目录标题 为什么会有跳表跳表的原理跳表的模拟实现准备工作find函数insert函数erase函数 测试效率比较 为什么会有跳表 在前面的学习过程中我们学习过链表这个容器,这个容器在头部和尾部插入数据的时间复杂度为O(1),但是该容器存在一个缺陷就是不管数据…...
为什么Tomcat的NIO在读取body时要模拟阻塞?
文章首发地址 Tomcat的NIO完全可以以非阻塞方式处理IO,为什么在读取body部分时要模拟阻塞呢?在Tomcat的NIO读取HTTP请求时,为了保证请求的正确性和可靠性,需要模拟阻塞模式,这是因为servlet规范里定义了ServletInputSt…...
26 | 谷歌应用APP数据分析
基于kaggle公开数据集,对谷歌应用市场的APP情况进行数据探索和分析。 from kaggle: https://www.kaggle.com/lava18/google-play-store-apps 分析思路: 0、数据准备 1、数据概览 2、种类对Rating的影响 3、定价策略 4、因素相关性分析 5、用户评价 6、总结 0、数据准备 (…...
BFS 五香豆腐
题目描述 经过谢老师n次的教导,dfc终于觉悟了——过于腐败是不对的。但是dfc自身却无法改变自己,于是他找到了你,请求你的帮助。 dfc的内心可以看成是5*5个分区组成,每个分区都可以决定的的去向,0表示继续爱好腐败&…...
opencv实战项目 手势识别-手势控制键盘
手势识别是一种人机交互技术,通过识别人的手势动作,从而实现对计算机、智能手机、智能电视等设备的操作和控制。 1. opencv实现手部追踪(定位手部关键点) 2.opencv实战项目 实现手势跟踪并返回位置信息(封装调用&am…...
1.作用域
1.1局部作用域 局部作用域分为函数作用域和块作用域。 1.函数作用域: 在函数内部声明的变量只能在函数内部被访问,外部无法直接访问。 总结: (1)函数内部声明的变量,在函数外部无法被访问 (2)函数的参数也是函数内部的局部变量 (3)不同函数…...
黑马B站八股文学习笔记
视频地址:https://www.yuque.com/linxun-bpyj0/linxun/vy91es9lyg7kbfnr 大纲 基础篇 基础篇要点:算法、数据结构、基础设计模式 1. 二分查找 要求 能够用自己语言描述二分查找算法能够手写二分查找代码能够解答一些变化后的考法 算法描述 前提&a…...
前端常用的上传下载文件的几种方式,直接上传、下载文件,读取.xlsx文件数据,导出.xlsx数据
一、通过调用接口下载文件 const onExport async () > {try {let res await axios.request({method: POST,url: 请求地址,responseType: blob,params: { data: null },headers: { Authorization: Bearer UserModule.token },//看看请求是否需要token});let reader new…...
FPGA应用学习笔记--时钟域的控制 亚稳态的解决
时钟域就是同一个时钟的区域,体现在laways语句边缘触发语句中,设计规模增大就会导致时钟不同步,有时差,就要设计多时钟域。 会经过与门的延时产生的新时钟域,这种其实不推荐使用,但在ascl里面很常见 在处理…...
AirServer是什么软件,手机屏幕投屏电脑神器
什么是 AirServer? AirServer 是适用于 Mac 和 PC 的先进的屏幕镜像接收器。 它允许您接收 AirPlay 和 Google Cast 流,类似于 Apple TV 或 Chromecast 设备。AirServer 可以将一个简单的大屏幕或投影仪变成一个通用的屏幕镜像接收器 ,是一款…...
如何使用 AT+WEBSERVER 指令实现自定义的 Webserver html 网页配网
开启 AT 固件中的 Webserver 指令和 FS 指令支持 乐鑫官网发布的默认通用 AT 固件不支持 webserver 配网功能, 需要用户自己搭建 esp-at 环境,并在 sdkconfig 中开启 webserver AT 指令 和 FS 指令的支持, 如下图所示: 测试 AT 固…...
期权定价模型系列【4】—期权组合的Delta-Gamma-Vega中性
期权组合的Delta-Gamma-Vega中性 期权组合构建时往往会进行delta中性对冲,在进行中性对冲后,期权组合的delta敞口为0,此时期权组合仍然存在gamma与vega敞口。因此研究期权组合的delta-gamma-vega敞口中性是有必要的。 本文旨在对delta-gamma-…...
k8sday02
第四章 实战入门 本章节将介绍如何在kubernetes集群中部署一个nginx服务,并且能够对其进行访问。 Namespace Namespace是kubernetes系统中的一种非常重要资源,它的主要作用是用来实现多套环境的资源隔离或者多租户的资源隔离。 默认情况下&…...
黑马头条项目学习--Day2: app端文章查看,静态化freemarker,分布式文件系统minIO
app端文章 Day02: app端文章查看,静态化freemarker,分布式文件系统minIOa. app端文章列表查询1) 需求分析2) 实现思路 b. app端文章详细1) 需求分析2) Freemarker概述a) 基础语法种类b) 集合指令(List和Map)c) if指令d) 运算符e) 空值处理f) …...
特语云用Linux和MCSM面板搭建 我的世界基岩版插件服 教程
Linux系统 用MCSM和DockerWine 搭建 我的世界 LiteLoaderBDS 服务器 Minecraft Bedrock Edition 也就是我的世界基岩版,这是 Minecraft 的另一个版本。Minecraft 基岩版可以运行在 Win10、Android、iOS、XBox、switch。基岩版不能使用 Java 版的服务器,…...
2023.8
编译 make install 去掉 folly armv8-acrc arrow NEON 相关链接 https://blog.csdn.net/u011889952/article/details/118762819 这里面的方案二,我之前也是用的这个 https://blog.csdn.net/zzhongcy/article/details/105512565 参考的此博客 火焰图 https://b…...
CSV文件编辑器——Modern CSV for mac
Modern CSV for Mac是一款功能强大、操作简单的CSV文件编辑器,适用于Mac用户快速、高效地处理和管理CSV文件。Modern CSV具有直观的用户界面,可以轻松导入、编辑和导出CSV文件。它支持各种功能,包括排序、过滤、查找和替换,使您能…...
【Linux】shell脚本忽略错误继续执行
在 shell 脚本中,可以使用 set -e 命令来设置脚本在遇到错误时退出执行。如果你希望脚本忽略错误并继续执行,可以在脚本开头添加 set e 命令来取消该设置。 举例1 #!/bin/bash# 取消 set -e 的设置 set e# 执行命令,并忽略错误 rm somefile…...
AtCoder 第409场初级竞赛 A~E题解
A Conflict 【题目链接】 原题链接:A - Conflict 【考点】 枚举 【题目大意】 找到是否有两人都想要的物品。 【解析】 遍历两端字符串,只有在同时为 o 时输出 Yes 并结束程序,否则输出 No。 【难度】 GESP三级 【代码参考】 #i…...
连锁超市冷库节能解决方案:如何实现超市降本增效
在连锁超市冷库运营中,高能耗、设备损耗快、人工管理低效等问题长期困扰企业。御控冷库节能解决方案通过智能控制化霜、按需化霜、实时监控、故障诊断、自动预警、远程控制开关六大核心技术,实现年省电费15%-60%,且不改动原有装备、安装快捷、…...
[ICLR 2022]How Much Can CLIP Benefit Vision-and-Language Tasks?
论文网址:pdf 英文是纯手打的!论文原文的summarizing and paraphrasing。可能会出现难以避免的拼写错误和语法错误,若有发现欢迎评论指正!文章偏向于笔记,谨慎食用 目录 1. 心得 2. 论文逐段精读 2.1. Abstract 2…...
ios苹果系统,js 滑动屏幕、锚定无效
现象:window.addEventListener监听touch无效,划不动屏幕,但是代码逻辑都有执行到。 scrollIntoView也无效。 原因:这是因为 iOS 的触摸事件处理机制和 touch-action: none 的设置有关。ios有太多得交互动作,从而会影响…...
docker 部署发现spring.profiles.active 问题
报错: org.springframework.boot.context.config.InvalidConfigDataPropertyException: Property spring.profiles.active imported from location class path resource [application-test.yml] is invalid in a profile specific resource [origin: class path re…...
JAVA后端开发——多租户
数据隔离是多租户系统中的核心概念,确保一个租户(在这个系统中可能是一个公司或一个独立的客户)的数据对其他租户是不可见的。在 RuoYi 框架(您当前项目所使用的基础框架)中,这通常是通过在数据表中增加一个…...
【SSH疑难排查】轻松解决新版OpenSSH连接旧服务器的“no matching...“系列算法协商失败问题
【SSH疑难排查】轻松解决新版OpenSSH连接旧服务器的"no matching..."系列算法协商失败问题 摘要: 近期,在使用较新版本的OpenSSH客户端连接老旧SSH服务器时,会遇到 "no matching key exchange method found", "n…...
纯 Java 项目(非 SpringBoot)集成 Mybatis-Plus 和 Mybatis-Plus-Join
纯 Java 项目(非 SpringBoot)集成 Mybatis-Plus 和 Mybatis-Plus-Join 1、依赖1.1、依赖版本1.2、pom.xml 2、代码2.1、SqlSession 构造器2.2、MybatisPlus代码生成器2.3、获取 config.yml 配置2.3.1、config.yml2.3.2、项目配置类 2.4、ftl 模板2.4.1、…...
Selenium常用函数介绍
目录 一,元素定位 1.1 cssSeector 1.2 xpath 二,操作测试对象 三,窗口 3.1 案例 3.2 窗口切换 3.3 窗口大小 3.4 屏幕截图 3.5 关闭窗口 四,弹窗 五,等待 六,导航 七,文件上传 …...
