news 2026/5/1 4:13:48

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/4/26 19:58:39

Android基础-Activity属性 android:configChanges

<activityandroid:name".activity.MoreFuncActivity"android:exported"false"android:configChanges"keyboardHidden|orientation|screenSize|navigation|keyboard" /> 项目清单文件中看到 android:configChanges"keyboardHidden|…

作者头像 李华
网站建设 2026/4/29 20:56:35

Kotaemon支持CI/CD持续集成部署吗?DevOps整合

Kotaemon支持CI/CD持续集成部署吗&#xff1f;DevOps整合 在企业级AI系统日益复杂的今天&#xff0c;一个常见的挑战浮出水面&#xff1a;如何将大语言模型&#xff08;LLM&#xff09;驱动的智能体从实验室原型平稳地推向生产环境&#xff1f;许多团队经历过这样的窘境——本地…

作者头像 李华
网站建设 2026/5/1 7:24:26

KotaemonA/B测试方案设计:实验组划分指导

Kotaemon A/B测试方案设计&#xff1a;实验组划分实践指南 在智能客服和企业级知识管理场景中&#xff0c;一个问答系统的准确性不再仅仅取决于大模型的能力&#xff0c;更依赖于背后整套检索增强生成&#xff08;RAG&#xff09;流程的精细调优。我们常常会遇到这样的问题&…

作者头像 李华
网站建设 2026/5/1 6:11:54

基于Kotaemon的会议室预订智能助手开发

基于Kotaemon的会议室预订智能助手开发 在现代企业办公环境中&#xff0c;一个看似简单的任务——“订个会议室”——却常常演变成一场耗时的协调战。员工需要打开日历系统、手动筛选空闲时段、确认设备配置、检查权限、拉群通知同事……稍有疏忽&#xff0c;就可能出现时间冲…

作者头像 李华
网站建设 2026/5/1 9:56:58

Kotaemon助力企业构建私有化知识库问答系统

Kotaemon助力企业构建私有化知识库问答系统 在当今企业数字化转型的浪潮中&#xff0c;知识不再只是静态文档的堆砌&#xff0c;而是驱动效率与决策的核心资产。然而&#xff0c;当员工面对分布在Confluence、SharePoint、本地服务器甚至个人笔记中的海量资料时&#xff0c;“我…

作者头像 李华
网站建设 2026/5/1 5:48:45

Kotaemon微服务架构拆分建议:适应大规模部署

Kotaemon微服务架构拆分建议&#xff1a;适应大规模部署 在企业智能对话系统逐渐成为客服、知识管理与自动化办公核心组件的今天&#xff0c;一个关键问题摆在了架构师面前&#xff1a;如何让原本为本地开发设计的AI框架&#xff0c;顺利演进为支撑高并发、可扩展、易维护的企业…

作者头像 李华