![](https://img-blog.csdnimg.cn/20201014180756918.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
链表
言寺之风雅颂
这个作者很懒,什么都没留下…
展开
-
约瑟夫问题(循环链表)
题目见另一篇博客: https://blog.csdn.net/macunshi/article/details/38499273 使用循环链表来做: #include "iostream" using namespace std; int n, m; struct node { int data; struct node *next; }; struct node *creat...原创 2019-05-10 10:19:25 · 253 阅读 · 0 评论 -
链表删除重复的元素
//链表删除重复的元素 #include <iostream> using namespace std; struct node { int data; struct node *next; }; //逆序建立链表 void createlist(struct node *L, int x) { struct node *p; p = (node*)malloc(siz...原创 2019-05-10 09:58:56 · 208 阅读 · 0 评论 -
双向链表
//双向链表,查找 key 的前驱和后继 #include "iostream" using namespace std; struct node { int data; struct node *before, *next; }; int main() { int n, key; cin >> n >> key; //n个数,要查找的数 key stru...原创 2019-05-08 21:13:08 · 114 阅读 · 0 评论 -
链表的逆置
//链表的就地逆置 #include "iostream" using namespace std; struct node { int data; struct node *next; }; int main() { int n; struct node *head,*p, *r, *q; head = (struct node *)malloc(sizeof(struct no...原创 2019-05-07 20:39:48 · 133 阅读 · 0 评论 -
有序链表的建立
第一种,直接在输入数据的时候找到要插入的合适位置。 //版本1 #include "iostream" using namespace std; struct node { int data; struct node *next; }; int main() { int n; cin>>n; //总共有n个数 struct node *head, *p, *q, *r...原创 2019-04-24 21:32:59 · 2646 阅读 · 0 评论