news 2026/7/29 4:23:14

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/7/28 20:52:05

使用Kotaemon构建城市公共服务智能应答系统

使用Kotaemon构建城市公共服务智能应答系统 在智慧城市加速推进的今天&#xff0c;市民对政务服务的期待早已超越“能办”&#xff0c;转向“好办、快办、主动办”。然而现实是&#xff1a;政策文件分散在数十个部门网站&#xff0c;办事流程动辄十几步&#xff0c;咨询热线永远…

作者头像 李华
网站建设 2026/7/25 22:52:12

8、从代码到内存:通用入门指南

从代码到内存:通用入门指南 1. 指针与数组在内存中的存储 在内存中,像 thinStringP (地址 0x01243040)和 wideStringP (地址 0x0124306C)这样的变量所存储的值仅 4 字节长,且不包含字符串数据。这是因为它们实际上是指向各自数组首字符的指针。例如, thinString…

作者头像 李华
网站建设 2026/7/28 18:36:00

14、游戏内存操作与代码注入技术解析

游戏内存操作与代码注入技术解析 1. 游戏内存保护与地址空间布局随机化 1.1 内存保护问题 在操作游戏内存时,如果改变原有的内存保护属性,游戏进程可能会出现 ACCESS_VIOLATION 异常并崩溃。例如,将内存保护从 PAGE_EXECUTE 改为 PAGE_READWRITE ,当内存未标记为可…

作者头像 李华
网站建设 2026/7/28 8:30:49

19、游戏中的控制流操纵与透视挂技术

游戏中的控制流操纵与透视挂技术 1. 编写 EndScene() 钩子 在游戏编程中,对 EndScene() 函数进行钩子操作非常有用。它能让你在一个完整的帧渲染之前进行拦截,从而在游戏循环中有效地执行自己的渲染代码。 EndScene() 函数在虚拟函数表(VF 表)中的索引为 42。以下是使…

作者头像 李华
网站建设 2026/7/28 17:02:12

Kotaemon离职面谈话术指南

Kotaemon&#xff1a;构建企业级智能对话系统的工程实践 在当今的企业数字化浪潮中&#xff0c;越来越多组织开始尝试将大模型技术应用于客户服务、内部知识管理和业务流程自动化。然而&#xff0c;许多项目在从PoC&#xff08;概念验证&#xff09;迈向生产部署时却频频受阻—…

作者头像 李华
网站建设 2026/7/28 21:30:28

Kotaemon能否支持中文全文检索?分词优化方案

Kotaemon能否支持中文全文检索&#xff1f;分词优化方案 在企业级智能问答系统日益普及的今天&#xff0c;一个关键问题浮出水面&#xff1a;当面对中文这种无空格分隔、语义高度依赖上下文的语言时&#xff0c;主流RAG框架是否真的能“读懂”我们的语言&#xff1f; 以Kotae…

作者头像 李华