当前位置: 首页 > news >正文

【C/C++】C语言实现单链表

C语言实现单链表

  • 简单描述
  • 代码
  • 运行结果

简单描述

  • 用codeblocks编译通过
  • 源码参考连接

https://gitee.com/IUuaena/data-structures-c.git

代码

  • common.h
#ifndef COMMON_H_INCLUDED
#define COMMON_H_INCLUDED#define ELEM_TYPE   int //!< 链表元素类型/*! @brief 返回值类型 */
typedef enum
{OK,             //!< 成功/正确NON_ALLOCATED,  //!< 内存分配失败NON_EXISTENT,   //!< 不存在ERROR           //!< 错误
} status_t;#endif // COMMON_H_INCLUDED
  • linked_list.h
#ifndef LINKED_LIST_H_INCLUDED
#define LINKED_LIST_H_INCLUDED#include "common.h"/*! @brief 链表结点 */
typedef struct linked_node
{ELEM_TYPE               data;   //!< 数据项struct linked_node*   next;   //!< 下一结点
} linked_node_t;typedef linked_node_t* linked_list_t;   //!< 链表status_t LinkedListCreate(linked_node_t** linked_list_head, ELEM_TYPE* elements, int elem_count);status_t LinkedListGetElem(linked_node_t* linked_list_head, int pos, ELEM_TYPE* elem);status_t LinkedListInsert(linked_node_t* linked_list_head, int pos, ELEM_TYPE elem);status_t LinkedListDelete(linked_node_t* linked_list_head, int pos, ELEM_TYPE* elem);status_t LinkedListMergeTwoSortedList(linked_node_t* list_a_head,linked_node_t* list_b_head,linked_node_t** merged_list_head);void LinkedListPrint(linked_node_t* linked_list_head);#endif // LINKED_LIST_H_INCLUDED
  • linked_list.c
/*!* @file linked_list.c* @author CyberDash计算机考研, cyberdash@163.com(抖音id:cyberdash_yuan)* @brief 单链表头文件* @version 1.0.0* @date 2022-07-10* @copyright Copyright (c) 2021*  CyberDash计算机考研*/#include <stdlib.h>
#include <stdio.h>
#include "linked_list.h"/*!* @brief **链表创建*** @param linked_list_head **链表头结点**(指针)* @param elements **数据项数组*** @param elem_count **数据项数量*** @return **执行结果*** @note** 链表创建* -------* -------** - 链表头结点分配内存 \n* &emsp; **if** 内存分配失败 : \n* &emsp;&emsp; 返回NON_ALLOCATED \n* - 链表头节点next设置为NULL \n* - 遍历数据项数组并插入链表结点 \n* &emsp; **for loop** 遍历数据项数组(从后向前) : \n* &emsp;&emsp; 分配当前链表结点内存 \n* &emsp;&emsp; **if** 内存分配失败 : \n* &emsp;&emsp;&emsp; 返回NON_ALLOCATED \n* &emsp;&emsp; 当前数据项elements[i]赋给当前链表结点的data \n* &emsp;&emsp; 链表头的next指向当前链表结点 \n*/
status_t LinkedListCreate(linked_node_t** linked_list_head, ELEM_TYPE* elements, int elem_count)
{*linked_list_head = (linked_node_t*)malloc(sizeof(linked_node_t)); // 链表头结点分配内存if (!(*linked_list_head)){return NON_ALLOCATED;}(*linked_list_head)->next = NULL;for (int i = elem_count - 1; i >= 0; i--){linked_node_t* linked_node = (linked_node_t*)malloc(sizeof(linked_node_t)); // 新结点分配内存if (!linked_node){return NON_ALLOCATED;}linked_node->data = elements[i];            // elements[i]赋给新结点数据项linked_node->next = (*linked_list_head)->next; // 新结点next赋值(*linked_list_head)->next = linked_node;       // linked_list_head->next指向新结点}return OK;
}/*!* @brief **链表获取某位置的结点数据*** @param linked_list_head **链表头结点**(指针)* @param pos **位置*** @param elem **保存结点数据项的变量**(指针)* @return **执行结果*** @note* 链表获取某位置的结点数据* ---------------------* ---------------------** - 初始化遍历指针cur和起始位置cur_post(从1开始, 区别于数组的从0开始) \n* - 遍历链表至位置pos \n* &emsp; **while** 未遍历至位置pos : \n* &emsp;&emsp; cur指向后一个结点 \n* &emsp;&emsp; cur_pos加1 \n* - 边界条件判断 \n* **if** 遍历指针cur指向NULL 或者 cur_pos大于pos : \n* &emsp; 返回NON_EXISTENT(不存在该位置的元素) \n* - 将位置pos的元素的data赋给参数elem指向的变量*/
status_t LinkedListGetElem(linked_node_t* linked_list_head, int pos, ELEM_TYPE* elem)
{linked_node_t* cur = linked_list_head->next;int cur_pos = 1;while (cur && cur_pos < pos){cur = cur->next;cur_pos++;}// 位置pos的结点不存在, 返回NON_EXISTENTif (!cur || cur_pos > pos){return NON_EXISTENT;}*elem = cur->data; // 将位置pos的数据项赋给*elemreturn OK;
}/*!* @brief **链表插入*** @param linked_list_head **链表头结点**(指针)* @param pos **位置**(在这个位置前执行插入)* @param elem **待插入的数据项*** @return **执行结果*** @note* 链表插入* -------* -------** - 初始化指针cur和insert_pos_predecessor \n* &emsp; cur用来遍历, 找到插入位置的前一节点, insert_pos_predecessor用来找该节点的位置 \n* - 找到插入位置 \n* &emsp; **while** cur不为NULL 或者 尚未遍历完整个链表 \n* &emsp;&emsp; cur指向下一个结点 \n* &emsp;&emsp; insert_pos_predecessor加1 \n* - 处理没有插入位置的情况 \n* &emsp; **if** 插入位置不存在 \n* &emsp;&emsp; 返回ERROR \n* - 执行插入 \n* &emsp; 分配结点内存 \n* &emsp; **if** 内存分配失败 : \n* &emsp;&emsp; 返回NON_ALLOCATED \n* &emsp; 插入节点设置data和next \n* &emsp; cur->next指向插入节点 \n*/
status_t LinkedListInsert(linked_node_t* linked_list_head, int pos, ELEM_TYPE elem)
{linked_node_t* cur = linked_list_head;int insert_pos_predecessor = 0; // 插入位置的前一位置, 初始化为0// 遍历到插入位置的前一位置while(!cur || insert_pos_predecessor < pos - 1){cur = cur->next;insert_pos_predecessor++;}// 如果插入位置不存在, 返回ERRORif (!cur || insert_pos_predecessor > pos - 1){return ERROR;}// 插入结点分配内存linked_node_t* insert_node = (linked_node_t*)malloc(sizeof(linked_node_t));if (!insert_node){return NON_ALLOCATED;}// 插入节点设置data和nextinsert_node->data = elem;insert_node->next = cur->next;// cur->next指向插入节点cur->next = insert_node;return OK;
}/*!* @brief **链表删除结点*** @param linked_list_head **链表头结点**(指针)* @param pos **删除结点位置*** @param elem **被删除结点数据项的保存变量**(指针)* @return **执行结果*** @note* 链表删除结点* ----------* ----------* - 初始化变量delete_node_predecessor和delete_pos_predecessor \n* &emsp; delete_node_predecessor(删除节点的前一节点指针)指向表头 \n* &emsp; delete_pos_predecessor(删除节点的前一节点的位置)初始值为0 \n* - 遍历至被删除结点 \n* - 处理不存在删除结点的情况 \n* - 删除结点 \n* &emsp; 指针delete_node指向delete_node_predecessor->next(被删除结点) \n* &emsp; delete_node_predecessor->next指向被删除结点的next \n* &emsp; 被删除结点的数据项赋给item \n* &emsp; 调用free释放被删除结点 \n*/
status_t LinkedListDelete(linked_node_t* linked_list_head, int pos, ELEM_TYPE* elem)
{linked_node_t* delete_node_predecessor = linked_list_head;    // 待删除结点前一结点(指针), 初始化指向链表头结点int delete_pos_predecessor = 0; // 待删除结点前一结点的位置, 初始化为0// 遍历到待删除结点的前一结点while(!(delete_node_predecessor->next) || delete_pos_predecessor < pos - 1){delete_node_predecessor = delete_node_predecessor->next;delete_pos_predecessor++;}// 位置pos的结点不存在, 返回NON_EXISTENTif (!(delete_node_predecessor->next) || delete_pos_predecessor > pos - 1){return NON_EXISTENT;}linked_node_t* delete_node = delete_node_predecessor->next; // delete_node指向待删除结点delete_node_predecessor->next = delete_node->next;*elem = delete_node->data;free(delete_node);  // 释放结点delete_node = NULL; // 避免野指针return OK;
}/*!* @brief **链表合并两个有序链表*** @param list_a_head **a链表的头结点**(指针)* @param list_b_head **b链表的头结点**(指针)* @param merged_list_head **合并链表的头结点**(二级指针)* @return **执行结果*** @note* 链表合并两个有序链表* -----------------* -----------------* **注**: 有序链表a和有序链表b合并, 合并至a链表 \n* - 初始化链表a的遍历指针a_cur和链表b的遍历指针b_cur \n* &emsp; a_cur指向链表a首元素结点 \n* &emsp; b_cur指向链表b首元素结点 \n* - 初始化合并链表的遍历指针 \n* &emsp; cur指向链表a头结点 \n* - 执行合并 \n* &emsp; **while** 链表a和链表b都未合并完 : \n* &emsp;&emsp; **if** 链表a当前元素 <= 链表b当前元素 : \n* &emsp;&emsp;&emsp; 合并链表当前元素(cur)的next指向链表a当前元素 \n* &emsp;&emsp;&emsp; 合并链表当前元素(cur)更新为链表a当前元素 \n* &emsp;&emsp;&emsp; 链表a当前元素向后移动一位(next) \n* &emsp;&emsp; **else** (链表a当前元素 > 链表b当前元素) : \n* &emsp;&emsp;&emsp; 合并链表当前元素(cur)的next指向链表a当前元素 \n* &emsp;&emsp;&emsp; 合并链表当前元素(cur)更新为链表a当前元素 \n* &emsp;&emsp;&emsp; 链表a当前元素向后移动一位(next) \n* - 剩余链表处理 \n* &emsp; 如果链表a有剩余, 将链表a加到合并链表尾部 \n* &emsp; 如果链表b有剩余, 将链表b加到合并链表尾部 \n*/
status_t LinkedListMergeTwoSortedList(linked_node_t* list_a_head,linked_node_t* list_b_head,linked_node_t** merged_list_head)
{linked_node_t* a_cur = list_a_head->next;linked_node_t* b_cur = list_b_head->next;*merged_list_head = list_a_head;linked_node_t* cur = list_a_head;while (a_cur && b_cur){if (a_cur->data <= b_cur->data){cur->next = a_cur;cur = a_cur;a_cur = a_cur->next;}else{cur->next = b_cur;cur = b_cur;b_cur = b_cur->next;}}if (a_cur){cur->next = a_cur;}if (b_cur){cur->next = b_cur;}return OK;
}/*!* @brief **打印链表*** @param linked_list_head **链表头结点*** @note* 打印链表* -------* -------* 遍历链表, 打印每一结点的数据项data \n*/
void LinkedListPrint(linked_node_t* linked_list_head)
{for (linked_node_t* cur = linked_list_head->next; cur != NULL; cur = cur->next){printf("%d ", cur->data);}printf("\n");
}
  • main.c
#include <stdio.h>
#include <stdlib.h>
#include "linked_list.h"void TestLinkedListCreate() {printf("\n");printf("|------------------------ CyberDash ------------------------|\n");printf("|                       测试链表的创建                        |\n");ELEM_TYPE arr[6] = { 1, 4, 2, 8, 5, 7 };    // 数据项数组linked_node_t* linked_list_head = NULL;     // 链表头结点linked_list_head初始化为NULLprintf("创建链表: ");// 调用LinkedListCreate创建链表LinkedListCreate(&linked_list_head, arr, sizeof(arr)/ sizeof(ELEM_TYPE));// 打印链表LinkedListPrint(linked_list_head);printf("\n-------------------------------------------------------------\n\n");
}/*!* @brief **测试链表获取结点数据*** @note* 测试链表获取结点数据* -----------------* -----------------* - 创建链表 \n* &emsp; 使用数组[1, 4, 2, 8, 5, 7]创建链表 \n* - 获取某位置结点数据 \n* &emsp; 获取并打印 \n*/
void TestLinkedListGetElem() {printf("\n");printf("|------------------------ CyberDash ------------------------|\n");printf("|                      测试链表的获取元素                      |\n");ELEM_TYPE arr[6] = { 1, 4, 2, 8, 5, 7 };    // 数据项数组linked_node_t* linked_list_head = NULL;     // 链表头结点linked_list_head初始化为NULLprintf("创建链表: ");// 调用LinkedListCreate创建链表LinkedListCreate(&linked_list_head, arr, sizeof(arr) / sizeof(ELEM_TYPE));// 打印链表LinkedListPrint(linked_list_head);int pos = 3;ELEM_TYPE data;LinkedListGetElem(linked_list_head, pos, &data);printf("位置%d的结点, 数据项: %d\n", pos, data);printf("\n-------------------------------------------------------------\n\n");
}/*!* @brief **测试链表删除结点*** @note* 测试链表删除结点* --------------* --------------* - 创建链表 \n* &emsp; 使用数组[1, 4, 2, 8, 5, 7]创建链表 \n* - 删除结点 \n* - 打印链表 \n*/
void TestLinkedListDelete() {printf("\n");printf("|------------------------ CyberDash ------------------------|\n");printf("|                      测试链表的删除结点                      |\n");ELEM_TYPE arr[6] = { 1, 4, 2, 8, 5, 7 };    // 数据项数组linked_node_t* linked_list_head = NULL;     // 链表头结点linked_list_head初始化为NULL// 调用LinkedListCreate创建链表printf("创建链表: ");LinkedListCreate(&linked_list_head, arr, sizeof(arr) / sizeof(ELEM_TYPE));// 打印链表LinkedListPrint(linked_list_head);int delete_pos = 4;             // 删除结点位置ELEM_TYPE delete_node_elem = 0; // 被删除结点数据项的保存变量printf("\n删除位置%d的结点(从1开始计数)\n\n", delete_pos);LinkedListDelete(linked_list_head, delete_pos, &delete_node_elem);// 打印链表printf("删除结点后的链表: ");LinkedListPrint(linked_list_head);printf("\n-------------------------------------------------------------\n\n");
}/*!* @brief **测试链表插入结点*** @note* 测试链表插入结点* --------------* --------------* - 创建链表 \n* &emsp; 使用数组[1, 4, 2, 8, 5, 7]创建链表 \n* - 插入结点 \n* - 打印链表 \n*/
void TestLinkedListInsert() {printf("\n");printf("|------------------------ CyberDash ------------------------|\n");printf("|                      测试链表的插入结点                      |\n");ELEM_TYPE arr[6] = { 1, 4, 2, 8, 5, 7 };    // 数据项数组linked_node_t* linked_list_head = NULL;     // 链表头结点linked_list_head初始化为NULL// 调用LinkedListCreate创建链表printf("创建链表: ");LinkedListCreate(&linked_list_head, arr, sizeof(arr) / sizeof(ELEM_TYPE));// 打印链表LinkedListPrint(linked_list_head);// 插入新元素LinkedListInsert(linked_list_head, 2, 9);LinkedListInsert(linked_list_head, 2, 10);LinkedListInsert(linked_list_head, 2, 11);// 打印链表printf("插入3个新结点后的链表: ");LinkedListPrint(linked_list_head);printf("\n-------------------------------------------------------------\n\n");
}/*!* @brief **测试链表有序链表合并*** @note** (有序)链表合并* ------------* ------------* - 创建链表1 \n* &emsp; 2 --> 4 --> 6 --> 8 \n* - 创建链表2 \n* &emsp; 1 --> 3 --> 5 --> 7 --> 9 --> 10 \n* - 合并链表 \n* &emsp; 1 --> 2 --> 3 --> 4 --> 5 --> 6 --> 7 --> 8 --> 9 --> 10 \n*/
void TestLinkedListMerge() {printf("\n");printf("|------------------------ CyberDash ------------------------|\n");printf("|                      测试有序链表的合并                      |\n");ELEM_TYPE elements1[4] = { 2, 4, 6, 8 };ELEM_TYPE elements2[6] = { 1, 3, 5, 7 , 9, 10};linked_node_t* linked_list_head1 = NULL;linked_node_t* linked_list_head2 = NULL;linked_node_t* merged_linked_list_head = NULL;printf("创建链表1:\n");LinkedListCreate(&linked_list_head1, elements1, sizeof(elements1) / sizeof(ELEM_TYPE));LinkedListPrint(linked_list_head1);printf("创建链表2:\n");LinkedListCreate(&linked_list_head2, elements2, sizeof(elements2) / sizeof(ELEM_TYPE));LinkedListPrint(linked_list_head2);printf("合并链表:\n");LinkedListMergeTwoSortedList(linked_list_head1, linked_list_head2, &merged_linked_list_head);LinkedListPrint(merged_linked_list_head);printf("\n-------------------------------------------------------------\n\n");
}int main()
{printf("你好!\n");TestLinkedListCreate();TestLinkedListGetElem();TestLinkedListDelete();TestLinkedListInsert();TestLinkedListMerge();return 0;
}

运行结果

你好!|------------------------ CyberDash ------------------------|
|                       测试链表的创建                        |
创建链表: 1 4 2 8 5 7-------------------------------------------------------------|------------------------ CyberDash ------------------------|
|                      测试链表的获取元素                      |
创建链表: 1 4 2 8 5 7
位置3的结点, 数据项: 2-------------------------------------------------------------|------------------------ CyberDash ------------------------|
|                      测试链表的删除结点                      |
创建链表: 1 4 2 8 5 7删除位置4的结点(1开始计数)删除结点后的链表: 1 4 2 5 7-------------------------------------------------------------|------------------------ CyberDash ------------------------|
|                      测试链表的插入结点                      |
创建链表: 1 4 2 8 5 7
插入3个新结点后的链表: 1 11 10 9 4 2 8 5 7-------------------------------------------------------------|------------------------ CyberDash ------------------------|
|                      测试有序链表的合并                      |
创建链表1:
2 4 6 8
创建链表2:
1 3 5 7 9 10
合并链表:
1 2 3 4 5 6 7 8 9 10-------------------------------------------------------------

相关文章:

【C/C++】C语言实现单链表

C语言实现单链表 简单描述代码运行结果 简单描述 用codeblocks编译通过 源码参考连接 https://gitee.com/IUuaena/data-structures-c.git 代码 common.h #ifndef COMMON_H_INCLUDED #define COMMON_H_INCLUDED#define ELEM_TYPE int //!< 链表元素类型/*! brief 返回值类…...

VBA数据库解决方案第九讲:把数据库的内容在工作表中显示

《VBA数据库解决方案》教程&#xff08;版权10090845&#xff09;是我推出的第二套教程&#xff0c;目前已经是第二版修订了。这套教程定位于中级&#xff0c;是学完字典后的另一个专题讲解。数据库是数据处理的利器&#xff0c;教程中详细介绍了利用ADO连接ACCDB和EXCEL的方法…...

蓝桥杯刷题-12-公因数匹配-数论(分解质因数)不是很理解❓❓

蓝桥杯2023年第十四届省赛真题-公因数匹配 给定 n 个正整数 Ai&#xff0c;请找出两个数 i, j 使得 i < j 且 Ai 和 Aj 存在大于 1 的公因数。 如果存在多组 i, j&#xff0c;请输出 i 最小的那组。如果仍然存在多组 i, j&#xff0c;请输出 i 最小的所有方案中 j 最小的那…...

机器视觉学习(十二)—— 绘制图形

目录 一、绘制函数参数说明 1.1 cv2.line(&#xff09;绘制直线 1.2 cv2.rectangle&#xff08;&#xff09;绘制矩形 1.3 cv2.circle&#xff08;&#xff09; 绘制圆形 1.4 cv2.ellipse&#xff08;&#xff09;绘制椭圆 1.5 cv2.polylines&#xff08;&#xff09;绘制…...

软考信息处理技术员2024年5月报名流程及注意事项

2024年5月软考信息处理技术员报名入口&#xff1a; 中国计算机技术职业资格网&#xff08;http://www.ruankao.org.cn/&#xff09; 2024年软考报名时间暂未公布&#xff0c;考试时间上半年为5月25日到28日&#xff0c;下半年考试时间为11月9日到12日。不想错过考试最新消息的…...

linux:du和df区别

文章目录 1. 概述2. du 命令2. df 命令3. 区别总结 1. 概述 du 和 df 都是 Linux 系统中用于查看磁盘空间使用情况的命令&#xff0c;但它们的功能和用法有所不同。 2. du 命令 du 是 “disk usage” 的缩写&#xff0c;用于显示文件或目录的磁盘使用情况。du 命令用于查看指…...

MacOS Docker 部署 Redis 数据库

一、简介 Redis是一个开源的、使用C语言编写的、基于内存亦可持久化的Key-Value数据库&#xff0c;它提供了多种语言的API&#xff0c;并支持网络交互。Redis的数据存储在内存中&#xff0c;因此其读写速度非常快&#xff0c;每秒可以处理超过10万次读写操作&#xff0c;是已知…...

个推助力小米汽车APP实现智能用户触达,打造智能出行新体验

4月3日&#xff0c;小米SU7首批交付仪式在北京亦庄的小米汽车工厂总装车间举行&#xff0c;全国28城交付中心也同步开启首批交付。随着小米SU7系列汽车的正式发售和交付&#xff0c;小米汽车APP迎来了用户体量的爆发式增长。 小米汽车APP是小米汽车官方推出的手机应用&#xff…...

科研 | SCI、SCIE、ESCI、JIF、IF、IEEE Fellow

文章目录 SCISCIESCIE和SCI的区别SCIE和ESCI的区别JIF和IF有什么不同吗&#xff1f;IEEE Fellow SCI 科学引文索引&#xff08;Science Citation Index&#xff0c;SCI&#xff09;是由Clarivate Analytics&#xff08;原Thomson Reuters&#xff09;维护的一个重要的学术引文…...

10倍提效!用ChatGPT编写系统功能文档。。。

系统功能文档是一种描述软件系统功能和操作方式的文档。它让开发团队、测试人员、项目管理者、客户和最终用户对系统行为有清晰、全面的了解。 通过ChatGPT&#xff0c;我们能让编写系统功能文档的效率提升10倍以上。 ​《Leetcode算法刷题宝典》一位阿里P8大佬总结的刷题笔记…...

【Linux进阶之路】地址篇

文章目录 一、ipv4地址1. 基本概念2. 分类3.CIDR4.特殊的ip地址 二、IP协议1. 协议字段2.分片与重组3.路由 三、NAT技术1.公有和私有2.NAT3.NAPT 四、ARP协议1.MAC地址2.ARP 五、DHCP协议六、DNS协议尾序 一、ipv4地址 1. 基本概念 概念&#xff1a;IP地址&#xff0c;英文全…...

代码随想录第34天| 1005.K次取反后最大化的数组和 134. 加油站 135. 分发糖果

1005.K次取反后最大化的数组和 1005. K 次取反后最大化的数组和 - 力扣&#xff08;LeetCode&#xff09; 代码随想录 (programmercarl.com) 贪心算法&#xff0c;这不就是常识&#xff1f;还能叫贪心&#xff1f;LeetCode&#xff1a;1005.K次取反后最大化的数组和_哔哩哔…...

Rust线程间通信通讯channel的理解和使用

Channel允许在Rust中创建一个消息传递渠道&#xff0c;它返回一个元组结构体&#xff0c;其中包含发送和接收端。发送端用于向通道发送数据&#xff0c;而接收端则用于从通道接收数据。不能使用可变变量的方式&#xff0c;线程外面修改了可变变量的值&#xff0c;线程里面是拿不…...

Vue3组件基础示例

组件是vue中最推崇的&#xff0c;也是最强大的功能之一&#xff0c;就是为了提高重用性&#xff0c;减少重复性的开发。 如何使用原生HTML方法实现组件化 在使用原生HTML开发时&#xff0c;我们也会遇到一些常见的功能、模块&#xff0c;那么如何在原生HTML中使用组件化呢&am…...

如何使用PL/SQL Developer工具导出clob字段的表?

1 准备测试数据 导出测试对象&#xff1a;表test_0102&#xff0c;others字段为clob类型 --创建中间表test_0101 create table test_0101( id number, name varchar2(20), others clob);--插入100条测试数据 beginfor i in 1..100 loopinsert into test_0101 values(i,i||_a,l…...

蓝桥杯刷题 深度优先搜索-[NewOJ P1158]N皇后(C++)

题目描述 n皇后问题&#xff1a;n 个皇后放置在 nn 的棋盘上&#xff0c;并且使皇后彼此之间不能相互攻击。 上面布局用序列2 4 6 1 3 5表示&#xff0c;第i个数字表示第i行皇后放的列号。 按照这种格式输出前3个解&#xff0c;并统计总解数。 输入格式 输入一个正整数n&a…...

python实例2.2:编写一个装饰器,计算任何一个函数执行的时间(详解及其知识点拓展)

目录 一、编写一个装饰器,计算任何一个函数执行的时间 二、装饰器详解,及其用法举例...

Jenkins 持续集成 【CICD】

持续集成 &#xff08;Continuous integration&#xff0c;简称CI&#xff09; 持续集成是一种开发实践&#xff0c;它倡导团队成员频繁的集成他们的工作&#xff0c;每次集成都通过自动化构建&#xff08;包括编译、构建、打包、部署、自动化测试&#xff09;来验证&#xff…...

【CHI】(十二)Memory Tagging

目录 1. Introduction 2. Message extensions 3. Tag coherency 4. Read transaction rules 4.1 TagOp values 4.2 Permitted initial MTE tag states 5. Write transactions 5.1 Permitted TagOp values 5.2 TagOp, TU, and tags relationship 6. Dataless transact…...

Vue - 你知道Vue组件之间是如何进行数据传递的吗

难度级别:中级及以上 提问概率:85% 这道题还可以理解为Vue组件之间的数据是如何进行共享的,也可以理解为组件之间是如何通信的,很多人叫法不同,但都是说的同一个意思。我们知道,在Vue单页面应用项目中,所有的组件都是被嵌套在App.vue内…...

金融涉外业务赋能,守护跨境金融安全

随着跨境金融业务的快速发展&#xff0c;银行、保险等金融机构的涉外业务日益增多&#xff0c;外籍客户开户、跨境转账、保险投保等业务&#xff0c;都需要进行严格的证件核验与身份确认。传统的人工核验模式&#xff0c;不仅效率低下&#xff0c;还难以应对复杂的证件伪造手段…...

【独家首发】NotebookLM语义搜索底层架构图谱(基于2024 Q2最新API逆向分析,含7层向量映射逻辑)

更多请点击&#xff1a; https://intelliparadigm.com 第一章&#xff1a;NotebookLM语义搜索功能全景概览 核心能力定位 NotebookLM 的语义搜索并非传统关键词匹配&#xff0c;而是基于用户上传文档&#xff08;PDF、TXT、Google Docs&#xff09;构建的私有知识图谱进行上下…...

Godot实战(一)—— 用C#构建2D躲避游戏的核心机制

1. 环境准备与项目初始化 第一次打开Godot引擎时&#xff0c;那个简洁的界面可能会让你有点不知所措。别担心&#xff0c;我们一步步来。点击"New Project"按钮&#xff0c;给你的游戏项目起个名字&#xff0c;比如"DodgeTheCreeps"。建议专门创建一个空文…...

红队实战靶场搭建与ATTCK攻击链复现

1. 红队靶场环境搭建全流程 搭建红队实战靶场是安全研究的必修课&#xff0c;但很多新手常被复杂的网络配置劝退。我去年给某金融企业做内网渗透培训时&#xff0c;就遇到过学员集体卡在靶机互连阶段的尴尬场面。下面分享一套经过20企业实战验证的搭建方法。 首先需要准备三台虚…...

自定义下载器开发:如何为Fetch扩展OkHttp和其他下载引擎

自定义下载器开发&#xff1a;如何为Fetch扩展OkHttp和其他下载引擎 【免费下载链接】Fetch The best file downloader library for Android 项目地址: https://gitcode.com/gh_mirrors/fetch/Fetch Fetch作为Android平台上最优秀的文件下载库&#xff0c;其强大的扩展性…...

OctoBase源码解析:深入理解Rust实现的本地优先数据库引擎 [特殊字符]

OctoBase源码解析&#xff1a;深入理解Rust实现的本地优先数据库引擎 &#x1f419; 【免费下载链接】OctoBase &#x1f419; OctoBase is the open-source database behind AFFiNE, local-first, yet collaborative. A light-weight, scalable, data engine written in Rust.…...

大语言模型在模块化布局优化中的应用与实战

1. 项目概述&#xff1a;当大语言模型遇见模块化布局优化在芯片设计和建筑规划领域&#xff0c;模块布局优化一直是个令人头疼的NP难问题。想象一下&#xff0c;你面前有16个形状各异的乐高积木&#xff08;模块&#xff09;&#xff0c;需要将它们严丝合缝地拼成一个矩形底板&…...

什么是“中国词元”?——解析中国AI自主生态的核心公式与关键平台

在当前的AI发展阶段&#xff0c;构建自主可控的产业生态已成为关键议题。本文将解析“中国词元”&#xff08;Chinese Tokens&#xff09;这一核心概念&#xff0c;并介绍其关键支撑平台——模力方舟Moark。文章面向AI开发者、企业技术决策者及生态关注者&#xff0c;旨在阐明如…...

UE5新手必看:给你的自定义Pawn加上碰撞,别再让它“穿墙”了!

UE5碰撞系统实战&#xff1a;从零构建防穿墙Pawn的完整指南 当你在UE5中第一次创建自定义Pawn时&#xff0c;最令人沮丧的莫过于看着自己精心设计的角色像幽灵一样穿过墙壁和障碍物。这种"穿模"现象不仅破坏游戏体验&#xff0c;更会导致后续游戏逻辑的全面崩溃。本文…...

毫米波雷达3D重建技术:挑战与RFconstruct系统创新

1. 毫米波雷达3D重建技术概述在自动驾驶感知系统中&#xff0c;毫米波雷达因其独特的物理特性正扮演着越来越关键的角色。与激光雷达和摄像头相比&#xff0c;工作在76-81GHz频段的毫米波雷达具有穿透雾霾、雨雪的能力&#xff0c;且不受光照条件影响&#xff0c;这使其成为全天…...