19 Commits

Author SHA1 Message Date
Serendipity 6429ae798f 同步本地改动 2025-10-23 17:19:07 +08:00
Serendipity e1fcb9b565 更新学习的数据结构 2025-10-19 22:16:38 +08:00
Serendipity a950a73c81 更新settings 2025-10-17 11:14:13 +08:00
Serendipity f127396a63 修复数据结构clock.c编译错误
- 添加缺失的MyFunction()函数实现
- 实现1到1000000求和的示例功能
- 修正CLK_TCK为CLOCKS_PER_SEC(现代C标准)
- 解决隐式函数声明的编译错误
- 程序现在可以正常编译和运行,正确测量函数执行时间
2025-10-17 11:08:29 +08:00
Serendipity 93c16edb5a 更新MD文件路径引用
- 修正主README.md中的所有路径引用,使其与当前文件结构一致
- 更新翁凯C语言学习指南链接路径
- 更新五子棋AI项目文档链接路径
- 更新数据结构学习文档链接路径
- 修正编译说明和学习模块使用指南中的目录路径
- 改进五子棋README.md的编译运行说明,增加Windows和Linux/macOS的分平台指导
- 确保所有文档链接和路径引用都能正确工作
2025-10-17 10:52:27 +08:00
Serendipity e691ab43cc 1 2025-10-17 08:44:54 +08:00
Serendipity 5e874ceb80 修复单链表程序退出功能
- 修复case 7退出选项无法正常退出程序的问题
- 在退出前添加freeList()调用释放链表内存,避免内存泄漏
- 使用return 0正常退出程序,替换原来的break语句
- 修正编译命令注释中的文件名引用
- 程序现在可以通过选择7正常退出
2025-10-16 20:41:54 +08:00
Serendipity ed6113b2f1 添加单链表的增删改查实现,替换原链表插入文件
- 新增:单链表的增删改查.c - 完整的单链表操作实现
- 包含功能:头插、尾插、按值删除、按位置删除、查找、修改、打印等
- 移除:链表插入.c - 替换为更完整的实现
- 优化了代码结构和用户交互界面
2025-10-16 19:04:59 +08:00
Serendipity 5510a78cc9 更新:修复VS Code PowerShell路径;完善数据结构代码(链表插入说明) 2025-10-15 20:04:41 +08:00
Serendipity dc70efb5bc 添加链表插入功能和更新VS Code配置 2025-10-13 22:51:35 +08:00
Serendipity 12412b3864 更新结构体实现插入元素程序:将strtol改为scanf输入方式 2025-10-10 21:05:29 +08:00
Serendipity af63d6c2c9 重新排列数组操作程序的菜单和函数顺序
- 将菜单选项按照插入、删除、修改、查找、排序的顺序重新排列
- 调整函数定义顺序与菜单选项保持一致
- 在每个操作前添加显示当前数组状态的功能
- 优化用户体验,使操作更加直观
2025-10-09 22:16:13 +08:00
Serendipity 247f41ff87 添加Gobang-Game项目推荐链接到README 2025-10-09 20:55:49 +08:00
Serendipity 91e3438bfb 更新README文档,添加GitHub链接和完善项目结构描述 2025-10-09 20:49:27 +08:00
Serendipity 5b7eccf414 修复编译警告:移除main函数未使用的argc参数 2025-10-09 20:24:52 +08:00
Serendipity 127ecdab8f Update C code projects and configurations 2025-08-04 13:00:16 +08:00
Serendipity c9e57b4d41 Update README: Add linked list delete and clear operations to chapter 13 2025-07-20 22:53:06 +08:00
Serendipity ac374e89bf Add new linked list operations: delete and clear functions 2025-07-20 22:51:19 +08:00
Serendipity 4f7a07025a 添加VS Code C++开发配置文件,包括c_cpp_properties.json、launch.json、settings.json和tasks.json 2025-07-20 22:31:52 +08:00
203 changed files with 9862 additions and 289 deletions
+1 -1
View File
@@ -4,8 +4,8 @@
# 排除IDE配置文件 # 排除IDE配置文件
.idea/ .idea/
.vscode/
.vs/ .vs/
.vscode/
# 排除Trae AI配置文件 # 排除Trae AI配置文件
.trae/ .trae/
+27
View File
@@ -0,0 +1,27 @@
{
"configurations": [
{
"name": "windows-gcc-x64",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "D:/Program Files/mingw64/bin/gcc.exe",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "windows-gcc-x64",
"compilerArgs": [
"-Wall",
"-Wextra",
"-Wshadow",
"-fsanitize=address",
"-g3"
]
}
],
"version": 4
}
+24
View File
@@ -0,0 +1,24 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "C/C++ Runner: Debug Session",
"type": "cppdbg",
"request": "launch",
"args": [],
"stopAtEntry": false,
"externalConsole": true,
"cwd": "d:/Code/C_code/数据结构/陈越数据结构",
"program": "d:/Code/C_code/数据结构/陈越数据结构/build/Debug/outDebug",
"MIMode": "gdb",
"miDebuggerPath": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
+60
View File
@@ -0,0 +1,60 @@
{
"C_Cpp_Runner.cCompilerPath": "gcc",
"C_Cpp_Runner.cppCompilerPath": "g++",
"C_Cpp_Runner.debuggerPath": "gdb",
"C_Cpp_Runner.cStandard": "c17",
"C_Cpp_Runner.cppStandard": "c++17",
"C_Cpp_Runner.msvcBatchPath": "C:/Program Files/Microsoft Visual Studio/VR_NR/Community/VC/Auxiliary/Build/vcvarsall.bat",
"C_Cpp_Runner.useMsvc": false,
"C_Cpp_Runner.warnings": [
"-Wall",
"-Wextra",
"-Wpedantic",
"-Wshadow",
"-Wformat=2",
"-Wcast-align",
"-Wconversion",
"-Wsign-conversion",
"-Wnull-dereference"
],
"C_Cpp_Runner.msvcWarnings": [
"/W4",
"/permissive-",
"/w14242",
"/w14287",
"/w14296",
"/w14311",
"/w14826",
"/w44062",
"/w44242",
"/w14905",
"/w14906",
"/w14263",
"/w44265",
"/w14928"
],
"C_Cpp_Runner.enableWarnings": true,
"C_Cpp_Runner.warningsAsError": false,
"C_Cpp_Runner.compilerArgs": [],
"C_Cpp_Runner.linkerArgs": [],
"C_Cpp_Runner.includePaths": [],
"C_Cpp_Runner.includeSearch": [
"*",
"**/*"
],
"C_Cpp_Runner.excludeSearch": [
"**/build",
"**/build/**",
"**/.*",
"**/.*/**",
"**/.vscode",
"**/.vscode/**"
],
"C_Cpp_Runner.useAddressSanitizer": false,
"C_Cpp_Runner.useUndefinedSanitizer": false,
"C_Cpp_Runner.useLeakSanitizer": false,
"C_Cpp_Runner.showCompilationTime": false,
"C_Cpp_Runner.useLinkTimeOptimization": false,
"C_Cpp_Runner.msvcSecureNoWarnings": false,
"files.associations": {}
}
+35
View File
@@ -0,0 +1,35 @@
{
"tasks":
[
{
"type": "shell",
"label": "C/C++: gcc.exe 生成活动文件",
"command": "D:\\Program Files\\mingw64\\bin\\gcc.exe",
"args":
[
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe",
"-Wall",
"-Werror",
"-std=c++17",
"-fsanitize=address",
"-static-libasan"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "调试器生成的任务。"
}
],
"version": "2.0.0"
}
@@ -16,6 +16,4 @@ int main()
} }
printf("%d\n",n); printf("%d\n",n);
return 0; return 0;
} }
+129
View File
@@ -0,0 +1,129 @@
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <stdbool.h>
#include <string.h>
#ifdef _WIN32
#include <windows.h>
#include <direct.h>
#endif
/**
* 链表操作示例程序
*
* 本程序演示了单向链表的基本操作:
* 1. 创建链表并添加节点
* 2. 遍历并打印链表
* 3. 在链表中查找特定值
* 4. 从链表中删除特定值的节点
*/
typedef struct _node
{
int value;
struct _node *next;
} Node;
typedef struct _list
{
Node *head;
Node *tail;
} List;
void add(List *pList, int value)
{
Node *p = (Node *)malloc(sizeof(Node));
p->value = value;
p->next = NULL;
// 将节点插入链表
Node *last = pList->head;
if (last != NULL)
{
while (last->next != NULL)
{
last = last->next;
}
// attach
last->next = p;
}
else
{
pList->head = p;
}
}
void print(List *pList)
{
Node *p;
for (p = pList->head; p; p = p->next)
{
printf("%d\t", p->value);
}
printf("\n");
}
int main()
{
// 设置控制台编码为UTF-8
#ifdef _WIN32
system("chcp 65001 > nul"); // 设置控制台编码为UTF-8
SetConsoleOutputCP(65001); // 设置控制台输出编码
SetConsoleCP(65001); // 设置控制台输入编码
#endif
List list;
list.head = NULL;
list.tail = NULL;
int number;
do
{
printf("请输入一个整数:");
scanf("%d", &number);
if (number != -1)
{
add(&list, number);
}
} while (number != -1);
print(&list);
scanf("%d", &number);
Node *p;
int isFound = 0;
for (p = list.head; p; p = p->next)
{
if (p->value == number)
{
printf("找到!\n");
isFound = 1;
break;
}
}
if (!isFound)
{
printf("未找到!\n");
}
Node *q;
for (q = NULL, p = list.head; p; q = p, p = p->next)
{
if (p->value == number)
{
if (q == NULL)
{
list.head = p->next;
}
else
{
q->next = p->next;
}
free(p);
printf("删除成功!\n");
break;
}
}
return 0;
}
@@ -46,6 +46,16 @@ void add(List* pList, int value)
} }
} }
void print(List* pList)
{
Node *p;
for (p=pList->head; p; p=p->next)
{
printf("%d\t", p->value);
}
printf("\n");
}
int main() int main()
{ {
// 设置控制台编码为UTF-8 // 设置控制台编码为UTF-8
@@ -69,6 +79,24 @@ int main()
} }
} while (number!=-1); } while (number!=-1);
print(&list);
scanf("%d", &number);
Node *p;
int isFound = 0;
for (p=list.head; p; p=p->next)
{
if (p->value==number)
{
printf("找到!\n");
isFound = 1;
break;
}
}
if (!isFound)
{
printf("未找到!\n");
}
return 0; return 0;
} }
+132
View File
@@ -0,0 +1,132 @@
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <stdbool.h>
#include <string.h>
#ifdef _WIN32
#include <windows.h>
#include <direct.h>
#endif
// !链表的清除
/*
1. 清除链表中的所有节点
2. 释放链表占用的内存
2.1 使用malloc申请的动态内存需要释放
2.2 用malloc申请的内存,即使没有赋值,也会被赋值一个特定的值
赋值就是使用,所以没必要为这种内存清空赋值
*/
typedef struct _node{
int value;
struct _node *next;
} Node;
typedef struct _list{
Node *head;
Node *tail;
} List;
void add(List* pList, int value)
{
Node *p=(Node*)malloc(sizeof(Node));
p->value = value;
p->next = NULL;
// 将节点插入链表
Node *last = pList->head;
if (last!=NULL)
{
while (last->next!=NULL)
{
last = last->next;
}
// attach
last->next = p;
}
else
{
pList->head = p;
}
}
void print(List* pList)
{
Node *p;
for (p=pList->head; p; p=p->next)
{
printf("%d\t", p->value);
}
printf("\n");
}
int main()
{
// 设置控制台编码为UTF-8
#ifdef _WIN32
system("chcp 65001 > nul"); // 设置控制台编码为UTF-8
SetConsoleOutputCP(65001); // 设置控制台输出编码
SetConsoleCP(65001); // 设置控制台输入编码
#endif
List list;
list.head = NULL;
list.tail = NULL;
int number;
do {
printf("请输入一个整数:");
scanf("%d", &number);
if (number!=-1)
{
add(&list, number);
}
} while (number!=-1);
print(&list);
scanf("%d", &number);
Node *p;
int isFound = 0;
for (p=list.head; p; p=p->next)
{
if (p->value==number)
{
printf("找到!\n");
isFound = 1;
break;
}
}
if (!isFound)
{
printf("未找到!\n");
}
Node *q;
for (q = NULL, p = list.head; p; q=p, p = p->next)
{
if (p->value == number)
{
if (q==NULL)
{
list.head = p->next;
}
else
{
q->next = p->next;
}
free(p);
printf("删除成功!\n");
break;
}
}
for (p=list.head; p; p=p)
{
q=p->next;
free(p);
}
return 0;
}

Some files were not shown because too many files have changed in this diff Show More