博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
链表API
阅读量:7178 次
发布时间:2019-06-29

本文共 1276 字,大约阅读时间需要 4 分钟。

#include 
#include
using namespace std;#define size 1000struct node{ int num; node *next; node *pre;};node NodeListPool[size];int index = 0;node nil;node *NIL;void init(){ NIL = & nil; NIL->next = NIL; NIL->pre = NIL; NIL->num = -100;}node *getNewNode(){ return &NodeListPool[index++];}void insert(node *target, node *newNode){ newNode->next = target->next; newNode->pre = target; target->next = newNode; newNode->next->pre = newNode;}node *search(int key){ node *tmp = NIL->next; while(tmp != NIL && tmp ->num != key) { tmp = tmp -> next; } return tmp;}void deleteNode(node *node){ node->pre->next = node->next; node->next->pre = node->pre;}int main(){ init(); node *tmpNode = NIL; for(int i = 0; i < 100 ;i++) { int tmp = rand()%100 + 1; cout << tmp << endl; node *newNode = getNewNode(); newNode ->num = tmp; insert(tmpNode,newNode); tmpNode = tmpNode->next; } cout << "-------------------------------------"<< endl; tmpNode = NIL; while(tmpNode->next != NIL) { cout << tmpNode->next->num << endl; tmpNode = tmpNode->next; } return 0;}

 

转载于:https://www.cnblogs.com/zyqBlog/p/8033834.html

你可能感兴趣的文章
LVM逻辑卷管理
查看>>
java crm 进销存 websocket即时聊天发图片文字 好友群组 SSM源码
查看>>
通俗讲解边缘计算,抓住信息革命的浪潮
查看>>
关于适配这件小事的前世今生
查看>>
【JS教程】JS小功能代码片段(一)
查看>>
Gradle 自动构建工具5.2.1发布了
查看>>
死磕 java集合之LinkedHashSet源码分析
查看>>
让WINXP也跑4G内存
查看>>
关于thinkphp 框架开启路径重写,无法获取Authorization Header
查看>>
IntelliJ IDEA 开发 JavaFx
查看>>
用TMG搭建×××服务器(四)---基于PPTP的站点到站点×××
查看>>
datatables表头与数据无法对齐的解决方案
查看>>
Cisco 路由器 secondary address实现RIPV1不连续子网
查看>>
启用 Open vSwitch - 每天5分钟玩转 OpenStack(127)
查看>>
review what i studied `date` - 2017-4-25
查看>>
Windows 2003服务器群集(负载均衡)的安装
查看>>
MySQL不支持InnoDB的解决方法
查看>>
信息收集之DNS信息收集 -- dnstracer
查看>>
Fiddler抓包HTTPS请求
查看>>
4月全球操作系统份额动态:Win 7以49.27%成新霸主
查看>>