#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); }C语言链表2
张小明
前端开发工程师
蜣螂优化(DBO)算法在工程实际中求目标函数最小值的例子:压力容器设计成本最小化的4变量4约束...
蜣螂优化(DBO)算法 工程实际,求目标函数最小值,图中所求例子为一个压力容器设计成本最小,为4变量,4个不等式约束。 采用罚函数将4约束问题转变为无约束问题。 代码注释完整,非常容易带入自己想要求的问题。深夜撸代码发…
12、游戏内存中常见数据结构解析
游戏内存中常见数据结构解析 在游戏开发和内存分析中,了解常见的数据结构及其在内存中的存储方式是非常重要的。下面将详细介绍几种常见的数据结构,包括 std::vector 、 std::list 和 std::map ,并说明如何判断游戏数据是否存储在这些结构中。 1. 字符串相关类 在处…
21、游戏响应式黑客技术全解析
游戏响应式黑客技术全解析 在游戏世界里,玩家们总是追求更快的反应速度和更多的游戏信息。而响应式黑客技术,就为玩家提供了一种超越人类反应极限的可能。 1. 游戏基础机制与ESP黑客技术 游戏中,常常会根据玩家的位置每帧重新计算当前楼层值,为了防止该值在每次重绘帧时…
26、游戏隐藏与反检测技术全解析
游戏隐藏与反检测技术全解析 在游戏开发与游玩过程中,为了避免游戏程序被调试、检测,开发者和玩家常常需要运用各种技术手段隐藏程序的行为和特征。下面将详细介绍一些常见的反调试、反检测技术及其实现方法。 反调试技术 当检测到调试器时,可以采用多种方法混淆控制流,…
Kotaemon网络安全问答:CVE漏洞快速查询
Kotaemon网络安全问答:CVE漏洞快速查询 在现代企业安全运营中,面对每天新增数十个的公开漏洞(CVE),安全团队正面临前所未有的信息过载压力。一个典型的场景是:某位安全分析师刚收到一封关于“Windows提权漏…
Kotaemon能否自动识别问题紧急程度?
Kotaemon能否自动识别问题紧急程度? 在企业智能化转型的浪潮中,客服系统早已不再满足于“有问必答”的基础功能。越来越多的组织发现,面对成千上万的用户请求,如果不能快速区分哪些是需要立即响应的“火警级”问题,哪些…