#include <bits/stdc++.h>
using namespace std; struct node
{
int data; // 数据
node* next; // 指针
}; node* create(int Array[])
{
node *p, *pre, *head; // head头节点, pre当前节点的前驱节点,p当前节点
head = new node;
head->next = NULL;
pre = head;
for (int i = 0; i < 5; i++)
{
// 创建新节点
p = new node;
// 将Array[i]赋给新建的节点作为数据域,也可以scanf输入
p->data = Array[i];
p->next = NULL;
pre->next = p;
// 更新
pre = p;
}
return head;
} int search(node* head, int x)
{
int count = 0;
node* p = head->next;
while (p != NULL)
{
if(p->data == x)
{
count++;
}
p = p->next;
}
return count;
} void insert(node* head, int pos, int x)
{
node* p = head; // 保护头指针
// 找到位置
for(int i = 0; i < pos - 1; i++)
{
p = p->next; // pos - 1是为了找到位置的前一个节点
}
node* q = new node;
q->data = x;
q->next = p->next;
p->next = q;
} void del(node* head, int x)
{
node* p = head->next;
node* pre = head;
while(p != NULL)
{
if(p->data == x)
{
pre->next = p->next;
delete(p); }
else
{
pre = p;
p = p->next;
} }
} int main()
{
int Array[5] = {5, 3, 6, 1, 2};
node* L = create(Array);
L = L->next;
while(L != NULL)
{
printf("%d", L->data);
L = L->next;
}
system("pause");
}

最新文章

  1. Web系统大规模并发——电商秒杀与抢购
  2. MVC -- 后台RedirectToAction传递实体类与字符串
  3. 【nodejs笔记——小知识点汇总】
  4. FreeBSD从零开始---安装后配置(三)
  5. 通过ksoap2-android来调用Web Service操作的实例
  6. ubuntu搭建svn服务器(转)
  7. SQL基础篇---函数及其函数配套使用的关键字
  8. live555
  9. BZOJ_1625_ [Usaco2007_Dec]_宝石手镯_(01背包)
  10. MySql数据库的基本原理及指令
  11. MySQL复制表-SELECT INTO FROM
  12. vtime.hpp
  13. 使用fastreport以代码方式创建报表
  14. selenium之关于 chromedriver的安装和使用
  15. nginx mp3
  16. 通过cookie验证用户登录
  17. java 判断上传文件大小
  18. 开源日志收集Exceptionless简单使用
  19. Java 正则表达式的实际应用
  20. 自己平时收集的css、html笔记(适合初级前端攻城狮)

热门文章

  1. logstash的filter之grok
  2. [noi1755]Trie
  3. 听说你想把对象存储当 HDFS 用,我们这里有个方案...
  4. 入门JavaScript正则表达式
  5. 8.3 k8s部署jenkins,通过pv/pvc结合NFS服务器持久化
  6. iNeuOS工业互联网操作系统,分布式云端控制安全策略和增加实时日志功能
  7. [NOI Online #3 提高组] 魔法值
  8. Congratulations, FYMS-OIers!
  9. LeeCode刷题笔记
  10. Mysql优化,ICP、BNL算法、BKA算法、MMR算法