diff --git a/README.md b/README.md index 887d50c..00066e8 100644 --- a/README.md +++ b/README.md @@ -7,23 +7,23 @@ + 能填多少坑取决于作者决定考哪个学校;如果决定的学校不是考408,那我只会更新那个学校的科目的总结(┓( ´∀` )┏)咕咕咕 -+ 如果对你有帮助有启发,欢迎点个star资瓷一下作者;同时欢迎有对内容更好想法/懂得xmind排版的朋友提交issue帮助这个项目更好 - -+ 或许你也可以参考这个[相似项目](https://github.com/SSHeRun/CS-Xmind-Note) ++ 如果对你有帮助有启发,欢迎**点个star**资瓷一下作者;同时欢迎有**对内容更好想法/懂得xmind排版**的朋友提交issue帮助这个项目更好 +> 或许你也可以参考[这个项目](https://github.com/SSHeRun/CS-Xmind-Note) + ![image](https://images.cnblogs.com/cnblogs_com/unknown404/1368664/o_200228080609138b9120a159048225d7ead2d9f7bea6.jpg) --- ## 计算机网络 -+ [x] 第一章 概论 -+ [x] 第二章 物理层 -+ [x] 第三章 数据链路层 -+ [x] 第四章 网络层 -+ [x] 第五章 运输层 -+ [x] 第六章 应用层 ++ [x] [第一章 概论](https://github.com/Alice-and-Bob/CS408/blob/master/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BD%91%E7%BB%9C/%E7%AC%AC%E4%B8%80%E7%AB%A0%20%E7%BB%AA%E8%AE%BA/%E7%AC%AC%E4%B8%80%E7%AB%A0%20%E6%A6%82%E8%BF%B0.xmind) ++ [x] [第二章 物理层](https://github.com/Alice-and-Bob/CS408/blob/master/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BD%91%E7%BB%9C/%E7%AC%AC%E4%BA%8C%E7%AB%A0%20%E7%89%A9%E7%90%86%E5%B1%82/%E7%AC%AC%E4%BA%8C%E7%AB%A0%20%E7%89%A9%E7%90%86%E5%B1%82.xmind) ++ [x] [第三章 数据链路层](https://github.com/Alice-and-Bob/CS408/blob/master/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BD%91%E7%BB%9C/%E7%AC%AC%E4%B8%89%E7%AB%A0%20%E6%95%B0%E6%8D%AE%E9%93%BE%E8%B7%AF%E5%B1%82/%E7%AC%AC%E4%B8%89%E7%AB%A0%20%E6%95%B0%E6%8D%AE%E9%93%BE%E8%B7%AF%E5%B1%82.xmind) ++ [x] [第四章 网络层](https://github.com/Alice-and-Bob/CS408/blob/master/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BD%91%E7%BB%9C/%E7%AC%AC%E5%9B%9B%E7%AB%A0%20%E7%BD%91%E7%BB%9C%E5%B1%82/%E7%AC%AC%E5%9B%9B%E7%AB%A0%20%E7%BD%91%E7%BB%9C%E5%B1%82.xmind) ++ [x] [第五章 运输层](https://github.com/Alice-and-Bob/CS408/blob/master/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BD%91%E7%BB%9C/%E7%AC%AC%E4%BA%94%E7%AB%A0%20%E8%BF%90%E8%BE%93%E5%B1%82/%E7%AC%AC%E4%BA%94%E7%AB%A0%20%E8%BF%90%E8%BE%93%E5%B1%82.xmind) ++ [x] [第六章 应用层](https://github.com/Alice-and-Bob/CS408/blob/master/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BD%91%E7%BB%9C/%E7%AC%AC%E5%85%AD%E7%AB%A0%20%E5%BA%94%E7%94%A8%E5%B1%82/%E7%AC%AC%E5%85%AD%E7%AB%A0%20%E5%BA%94%E7%94%A8%E5%B1%82.xmind) ## 数据结构 -+ [x] 第一章 绪论 ++ [x] [第一章 绪论](https://github.com/Alice-and-Bob/CS408/blob/master/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/%E7%AC%AC%E4%B8%80%E7%AB%A0%20%E7%BB%AA%E8%AE%BA/%E7%AC%AC%E4%B8%80%E7%AB%A0%20%E7%BB%AA%E8%AE%BA.xmind) + [ ] 第二章 线性表 + [ ] 第三章 栈和队列 + [ ] 第四章 树与二叉树 diff --git a/数据结构/第二章 线性表/单链表.cpp b/数据结构/第二章 线性表/单链表.cpp new file mode 100644 index 0000000..36be526 --- /dev/null +++ b/数据结构/第二章 线性表/单链表.cpp @@ -0,0 +1,150 @@ +/*** + * @Author: Alice-and-Bob + * @Date: 2020-03-31 22:03:34 + * @LastEditTime: 2020-04-02 09:30:54 + * @LastEditors: Alice-and-Bob + * @Description: 线性表基本操作在链表上的cpp实现,代码实现不全,不能运行;用于演示算法步骤 + * @******************************************* + * @* 全世界程序员,联合起来! * + * @* Programmers of all lands, Unite! * + * @* программист всех стран, соединяйтесь! * + * @******************************************* + */ + +/*------------------------单链表------------------------*/ + +#define END 1000000 //预先确定的结束值 +typedef struct LNode +{ + int data; + struct LNode *next; +} LNode, *LinkList; + +//头插法建立链表 +LinkList List_HeadInsert(Linklist &L) +{ + + LNode *s; + int x; + L = (LinkList)malloc(sizeof(LNode)); + L.next = NULL; + while (cin >> x) + { + if (x == END) + { + break; + } + else + { + s = (LinkList)malloc(sizeof(LNode)); + s.data = x; + s.next = L.next; + L.next = s; + } + } + return L; +} +//尾插法建立链表 +LinkList List_TailInsert(LinkList L) +{ + int x; + L = (LinkList)malloc(sizeof(LNode)); + LNode *s, *t = L; //t是尾指针,总指向链表最后一个节点;s是临时节点 + while (cin >> x) + { + if (x == END) + { + break; + } + else + { + s = (LinkList)malloc(sizeof(LNode)); + s.data = x; + s.next = NULL; + r.next = s; + r = r.next; + } + } + //r.next = NULL; + return L; +} +//按序号查找节点 +LNode *GetElem(LinkList L, int i) +{ + LNode *s = L.next; + int j = 1; + if (i == 0) + { + return L + } + else if (i < 1) + { + return NULL; + } + + while (s && j < i) + { + s = s.next; + j++; + } + return s; +} +//按值查找节点 +LNode *LocalteElem(LinkList L, int x) +{ + LNode *s = L.next; + while (s.data != x && s.next != NULL) + { + s = s.next; + } + return s; +} +//在某个给定节点前插 +{//前插操作 + p = GetElem(L, i - 1); //找到要插入的前驱节点 + s.next = p.next; + p.next = s; +} +{//后插转前插 + s.next = p.next; + p.next = s; + temp = p.data; + p.data = s.data; + s.data = temp; +} +//删掉某个给定节点 +{//前删操作 + p = GetElem(L, i-1); + q = p.next; + p.next = q.next; + free(q); +} +{//后删转前删 + q = p.next; + p.data = p.next.data; + p.next = q.next; + free(q); +} + + + +/*------------------------改进链表----------------------*/ +//双链表 +typedef struct DNode +{ + ElemType data; + struct DNode *prior,*next;//前驱指针,后继指针 +}; +//插入节点 +{ + s.next = p.next; + p.next.prior = s; + s.prior = p; + p.next = s; +} +//删除节点 +{ + p.next = q.next; + q.next.prior = p; + free(q); +} diff --git a/数据结构/第二章 线性表/批注 2020-03-26 232754.png b/数据结构/第二章 线性表/批注 2020-03-26 232754.png new file mode 100644 index 0000000..3955b45 Binary files /dev/null and b/数据结构/第二章 线性表/批注 2020-03-26 232754.png differ diff --git a/数据结构/第二章 线性表/批注 2020-03-27 122454.png b/数据结构/第二章 线性表/批注 2020-03-27 122454.png new file mode 100644 index 0000000..cdbeab9 Binary files /dev/null and b/数据结构/第二章 线性表/批注 2020-03-27 122454.png differ diff --git a/数据结构/第二章 线性表/批注 2020-03-27 124407.png b/数据结构/第二章 线性表/批注 2020-03-27 124407.png new file mode 100644 index 0000000..335d30e Binary files /dev/null and b/数据结构/第二章 线性表/批注 2020-03-27 124407.png differ diff --git a/数据结构/第二章 线性表/批注 2020-03-27 124636.png b/数据结构/第二章 线性表/批注 2020-03-27 124636.png new file mode 100644 index 0000000..a73cf33 Binary files /dev/null and b/数据结构/第二章 线性表/批注 2020-03-27 124636.png differ diff --git a/数据结构/第二章 线性表/第二章 线性表.xmind b/数据结构/第二章 线性表/第二章 线性表.xmind new file mode 100644 index 0000000..31b33c2 Binary files /dev/null and b/数据结构/第二章 线性表/第二章 线性表.xmind differ diff --git a/数据结构/第二章 线性表/顺序表.cpp b/数据结构/第二章 线性表/顺序表.cpp new file mode 100644 index 0000000..ae9b09c --- /dev/null +++ b/数据结构/第二章 线性表/顺序表.cpp @@ -0,0 +1,72 @@ +/*** + * @Author: Alice-and-Bob + * @Date: 2020-03-26 23:45:49 + * @LastEditTime: 2020-03-27 12:05:27 + * @LastEditors: Alice-and-Bob + * @Description: 顺序表的基本操作cpp实现 + * @ + * @全世界无产者,联合起来! + * @Workers of all lands, Unite! + * @Пролетарии всех стран, соединяйтесь! + */ + +bool ListInsert(SqList &L, int i, Elemtype e) +{ + /*** + * @description:实现把元素e插入到顺序表L的第i个位置 + * @param {type} + * @return: + */ + if (i < 0 || i > L.length + 1) + { + return false; + } + if (L.length >= MaxSize) + { + return false; + } + for (int j = L.length; j >= i; j--) + { + L.data[j] = L.data[j - 1]; + } + L.data[i - 1] = e; + L.length++; + return true; +} + +bool ListDelete(SqList &L, int i, Elemtype &e) +{ + /*** + * @description:实现删除顺序表L的第i个元素,使用e返回被删除的元素 + * @param {type} + * @return: + */ + if (i < 0 || i > L.length + 1) + { + return false; + } + e = L.data[i - 1]; + for (int j = i; j < L.length; j++) + { + L.data[j - 1] = L.data[j]; + } + L.length--; + return true +} + +int LocateElem(SqList L, ElemType e) +{ + /*** + * @description: 实现在顺序表里按序查找第一个值为e的元素 + * @param {type} + * @return: + */ + for (int i = 0; i < L.length; i++) + { + if (L.data[i] == e) + { + return i + 1; + } + } + return 0; +} \ No newline at end of file