news 2026/6/17 9:27:12

C语言链表2

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
C语言链表2
#include<stdio.h> #include<stdlib.h> struct node{ int date; struct node* next; }; struct node* creat(int info){ //创建一个节点 struct node* newnode=(struct node*)malloc(sizeof(struct node)); if(newnode==NULL){ printf("error\n"); exit(1); } newnode->date=info; newnode->next=NULL; return newnode; } void add(struct node** head, int info){ //在链尾接上节点 struct node* newnode=creat(info); if(*head==NULL){ *head =newnode; return; } struct node* now=*head;//当前指针不为空 while(now->next!=NULL){ now=now->next; } now->next=newnode; } void coutout(struct node* head){ //遍历链表输出 struct node* now=head; printf("following is the list:\n"); while(now!=NULL){ printf("%d ",now->date); now=now->next; } printf("\n"); } void freelist(struct node* head){ //释放内存 struct node* t; while(head!=NULL){ t=head; head=head->next; free(t); } } void insert(struct node* head,int k,int date){ //插入节点 if(head==NULL){ printf("empty\n"); return; } struct node* now=head; for(int i=1;i<k&&now!=NULL;i++){ now=now->next; } if(now==NULL){ printf("over the list\n"); return; } struct node* newnode=creat(date); newnode->next=now->next; now->next=newnode; } void deletenode(struct node** head,int k){ if(*head==NULL){ printf("the list is empty\n"); return; } struct node* now=*head; struct node* prev=NULL; for(int i=1;i<k&&now!=NULL;i++){ prev=now; now=now->next; } if(now==NULL){ printf("over the list\n"); return; } if(prev==NULL){ *head=now->next; }else{ prev->next=now->next; } free(now); } int main(){ struct node* head=NULL; int num; scanf("%d",&num); while(num--){ int t; scanf("%d",&t); add(&head,t); } coutout(head); freelist(head); }
版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/6/16 16:20:08

Eclipse+maven+selenium自动化测试用例入门

相关的开发环境搭建参考以下文章&#xff1a; Eclipsemavenselenium自动化测试开发环境搭建 确认环境搭建成功后&#xff0c;在src/test/java目录下&#xff0c;defaut package右键新建class&#xff0c;命名为&#xff1a;GoogleTest&#xff0c;相关代码如下&#xff1a; i…

作者头像 李华
网站建设 2026/6/13 20:22:10

Kotaemon在政务智能问答中的合规性设计考量

Kotaemon在政务智能问答中的合规性设计考量 在政务服务日益智能化的今天&#xff0c;公众对AI助手的期待早已超越了“能答上来”&#xff0c;而是要求它“答得准、说得清、可追溯”。一个回答错误可能误导市民错过申报时限&#xff0c;一次数据泄露可能动摇公众对数字政府的信任…

作者头像 李华
网站建设 2026/6/16 6:14:35

Kotaemon支持批量导入知识文档并自动索引

Kotaemon支持批量导入知识文档并自动索引 在企业智能化转型的浪潮中&#xff0c;一个常见却棘手的问题浮出水面&#xff1a;如何让AI真正“懂”企业的内部知识&#xff1f;客服机器人面对新产品手册答非所问&#xff0c;技术支持系统对最新政策变更毫无反应——这些并非模型能力…

作者头像 李华
网站建设 2026/6/15 7:16:02

18、游戏中的控制流操作与Direct3D钩子技术

游戏中的控制流操作与Direct3D钩子技术 1. Adobe AIR模块钩子实现 在游戏开发与调试过程中,有时需要对特定模块的代码进行钩子操作,以监控或修改其行为。这里以Adobe AIR.dll模块为例,介绍如何实现钩子。 1.1 两部分近调用钩子设计 设计了一个两部分的近调用钩子。第一部…

作者头像 李华
网站建设 2026/6/16 18:05:25

20、游戏透视与视野拓展技巧揭秘

游戏透视与视野拓展技巧揭秘 在游戏世界中,玩家们总是希望能够获得更多的信息和优势,以提升自己的游戏体验和竞技水平。本文将深入探讨几种常见的游戏作弊技巧,包括穿墙透视、变焦透视、抬头显示(HUD)等,以及它们的原理和实现方法。 1. Z缓冲与穿墙透视 在游戏渲染中,…

作者头像 李华
网站建设 2026/6/15 9:47:17

Kotaemon多路召回策略设计:dense+sparse+colbert

Kotaemon多路召回策略设计&#xff1a;densesparsecolbert 在构建智能问答系统时&#xff0c;我们常常面临一个核心矛盾&#xff1a;大模型虽然能“说”&#xff0c;但未必“知道”。尤其是在企业级场景中&#xff0c;用户的问题往往涉及具体政策、产品条款或专业术语&#xf…

作者头像 李华