From cf5b7696d2d83d9d3b5dabc3b3ee680b37edf11a Mon Sep 17 00:00:00 2001 From: XiaoLFeng Date: Sat, 20 May 2023 18:07:57 +0800 Subject: [PATCH] Upload --- .idea/.gitignore | 9 ++++++++ LICENSE | 21 +++++++++++++++++++ README.md | 8 +++++++ main.cpp | 54 ++++++++++++++++++++++++++++++++++++++++++++---- 4 files changed, 88 insertions(+), 4 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 LICENSE create mode 100644 README.md diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..141b0db --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,9 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml +# 基于编辑器的 HTTP 客户端请求 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +/cmake-bui diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..ac9eb7e --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2016-2023 筱锋xiao_lfeng + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..54ce850 --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +# DataStructure_LinkList_C + +高等院校计算机必修课(基于C语言数据结构) —— 链表(单链表) + +作者:[筱锋xiao_lfeng](https://www.x-lf.com/) + +注意:代码不更新,接收用户PR。 +若使用请遵循MIT开源协议 \ No newline at end of file diff --git a/main.cpp b/main.cpp index bc8f460..7607a0d 100644 --- a/main.cpp +++ b/main.cpp @@ -1,6 +1,52 @@ -#include +/* + * 代码说明 + * 代码由 筱锋xiao_lfeng 编写 + * 其开发者由此互联网ICP备案作者编写:粤ICP备2022014822号 + */ + +#include + +typedef struct { + char no[8]; //8位学号 + char name[20]; //姓名 + int score; //成绩 +} Student; + +typedef struct Node { + Student data; //数据域 + struct Node *next; //指针域 +} LNode; + +//初始化一个学生信息链表,根据指定学生个数,逐个输入学生信息 +void CreatStuList(LNode *&list) { + list = new LNode; +} + +//逐个显示学生表中所有学生的相关信息 +void show(LNode *&list); + +//根据姓名进行查找,若存在则输出此学生的信息,并返回逻辑序号,否则输出“无此人”并返回0; +int findByName(LNode *&list, char name[]); + +//输出逻辑序号pos相应的学生信息(学号,姓名,成绩) +int Position(int pos, LNode *&list); + +//给定一个学生信息,插入到表中指定的位置 +int PInsert(int pos, LNode *&list, Student student); + +// 删除指定位置的学生记录 +int Delete(int pos, LNode *&list); + +//统计表中学生人数 +int Count(LNode *&list); + +//释放链表 +void DestroyList(LNode *&list); + int main() { - std::cout << "Hello, World!" << std::endl; - return 0; -} + // 创建链表节点 + LNode *lNode; + CreatStuList(lNode); + +} \ No newline at end of file