当前位置: 首页 > news >正文

餐饮网站建设网上免费注册网站

餐饮网站建设,网上免费注册网站,wordpress4.9.8优化,体育彩票网站开发方案不带头结点的节点因为插入删除的时候会改变或者删除第一个节点#xff0c;所以要引入二级指针进行一系列的操作 头文件 #pragma once //不带头结点的单链表 typedef struct Node {int data;//数据Node * next;//存放下一个元素的地址 }Node; //初始化 void InitList(Node **p…不带头结点的节点因为插入删除的时候会改变或者删除第一个节点所以要引入二级指针进行一系列的操作 头文件 #pragma once //不带头结点的单链表 typedef struct Node {int data;//数据Node * next;//存放下一个元素的地址 }Node; //初始化 void InitList(Node **ps); //头插 bool Insert_Head(Node **ps,int val); //尾插 bool Insert_Tail(Node **ps,int val); //按位置插入 bool Insert_Pos(Node **ps,int pos,int val); //删除某个节点 bool Delete_Node(Node **ps,int key); //删除整个链表 bool Delete_List(Node **ps); //查找 Node *Search(Node *ps,int key); //链表长度 int GetLength(Node *ps); //打印链表的值 void Show(Node* ps); cpp文件 #includeiostream #includeassert.h #includeNoList.h using namespace std;void InitList(Node* *ps) {assert(ps ! NULL);*ps NULL; }static Node* BuyNode(int val) {Node *pnewnode new Node();pnewnode-data val;pnewnode-next NULL;return pnewnode; } bool Insert_Head(Node* *ps,int val) {assert(ps ! NULL);Node* pnewnode BuyNode(val);pnewnode-next *ps;*ps pnewnode;return true; }bool Insert_Tail(Node* *ps,int val) {assert(ps ! NULL);Node* pnewnode BuyNode(val);Node* pTail *ps;if(pTail NULL){*ps pnewnode;//}else{ while(pTail-next ! NULL){pTail pTail-next;}pTail-next pnewnode;}return true; }bool Insert_Pos(Node* *ps,int pos,int val) {assert(ps ! NULL);Node * q *ps;for(int i 0;ipos;i){q q-next;}Node *p BuyNode(val);p-next q-next;q-next p;return true; }bool Delete_Node(Node* *ps,int key) {assert(ps ! NULL);Node* p Search(*ps,key);if(p NULL){return false;}//删除的节点是第一个节点也是最后一个节点if(p *ps){delete p;p NULL;/ps NULL;/}//删除的节点不是尾结点else if(p-next ! NULL){Node * q p-next;p-data q-data;p-next q-next;delete q;q NULL;}//节点有很多删除的节点是尾结点else if(p -next NULL){Node* q *ps;for(;q-next! NULL;q q-next);/*q -next NULL;q-next -data NULL;delete (q-next);*/q -next NULL;delete (q-next);p NULL;}return true; }bool Delete_List(Node* *ps) {assert(ps ! NULL);Node* p;//Node* q p;while(*ps ! NULL){p *ps;*ps p-next;delete p;}return true; }Node* Search(Node* ps,int key) {assert(ps ! NULL);Node * q ps;while(q ! NULL){if(key q-data){return q;}q q-next;}return NULL; }int GetLength(Node *ps) {assert(ps ! NULL);int length 0;for(Node* q ps;q! NULL;q q-next){length;}return length; }void Show(Node* ps) {for(Node *q ps;q! NULL;q q-next){cout q-data ;}cout endl; } 主函数 #includeiostream #includeassert.h #includeNoList.h using namespace std;int main() {Node* head;InitList(head);/*for(int i 0;i10;i){Insert_Head(head,i);}*/for(int i 0;i10;i){Insert_Tail(head,i,i);}Show(*head);cout GetLength(head) endl;Insert_Pos(head,5,111);Show(*head);cout GetLength(head) endl;Delete_Node(head,5);Show(head);cout GetLength(head) endl;Delete_List(head);Show(head);return 0; }
http://www.pierceye.com/news/149867/

相关文章:

  • 何为响应式网站太原自助建站
  • 网站建设方案书怎么写安徽和住房建设厅网站
  • 北京市住房和城乡建设厅官方网站重庆百度seo整站优化
  • 备案ip 查询网站查询网站河南建筑职业技术学院
  • 均安公司网站建设免费建手机个人网站
  • 南京做网站的网络公司排名wordpress发邮件更新
  • 抽奖的网站怎么做美食类网站模板
  • 自己建一个网站难吗网络安全行业公司排名
  • 做招聘的h5用哪个网站企业网站需要多大空间
  • 织梦 公司网站模板html5网站开发的源码
  • 晋江网站建设公司电脑培训网
  • 电子商务网站开发的题网站关键词排名怎么提升
  • 在百度网站备案查询上显示未备案是什么意思wordpress资源分享主题
  • 夏县做网站郑州做商城网站
  • 网站首页推荐网络服务提供者发现用户利用其网络服务对未成年
  • 中外网站建设区别微信软文是什么意思
  • 苏州网站建设极简幕枫卫浴网站建设
  • 优秀企业网站欣赏网站的备案怎么处理
  • 怎样做古玩网站毕业设计开题报告网站开发
  • 西安网站 建设app注册推广
  • 丹徒网站建设公司代理公司注册价格
  • 网站建站建设网站中国商标商标查询网
  • 机械加工网站平台南京app制作开发公司
  • 用vs2008做网站教程seo推广网址
  • 正规制作网站公司哪家好视觉传达设计专业作品集
  • 做网站多少钱特惠西宁君博s网站网站建设多少钱
  • 建筑模版东莞网站建设技术支持手机网站开发学习
  • 专业网站建设效果显著做设计找参考的设计网站有那些
  • 最新网站建设技术2022年新闻摘抄简短
  • 手机网站总是自动跳转最吃香的男生十大手艺