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

南京网站建设 雷仁网防爆玻璃门网站建设

南京网站建设 雷仁网,防爆玻璃门网站建设,seo排名哪家正规,网站加载速度慢实现功能BuySListNode ————————————申请一个新节点并赋值SListLength —————————————计算链表的长度SListPushBack————————————尾插SListPushFront————————————头插SListPopBack—————————————尾删SListPopFront—…实现功能BuySListNode ————————————申请一个新节点并赋值SListLength —————————————计算链表的长度SListPushBack————————————尾插SListPushFront————————————头插SListPopBack—————————————尾删SListPopFront————————————头删SListFindByVal————————————按值查找链表SListFindByPos————————————按位置查找链表SListInsertAfter————————————任意位置插入SListEraseAfter————————————任意位置删除SListPrint——————————————打印链表SList.h#pragma once#define _CRT_SECURE_NO_WARNINGS 1#include stdio.h #include stdlib.h #include stdbool.htypedef int SLTDataType;typedef struct SLTNode {SLTDataType data;struct SLTNode* next; }SLTNode;//申请一个新节点并赋值 extern SLTNode* BuySListNode(SLTDataType x);//计算链表的长度 extern int SListLength(SLTNode* phead);//尾插 extern void SListPushBack(SLTNode** pphead, SLTDataType x);//头插 extern void SListPushFront(SLTNode** pphead, SLTDataType x);//尾删 extern void SListPopBack(SLTNode** pphead);//头删 extern void SListPopFront(SLTNode** pphead);//按值查找链表 extern SLTNode* FindByVal(SLTNode* phead, SLTDataType x); extern void SListFindByVal(SLTNode* phead, SLTDataType x);//按位置查找链表 void FindByPos(SLTNode* phead, int pos, SLTNode** pp_aim1, int* p_aim2); extern void SListFindByPos(SLTNode* phead, int pos);//任意位置插入 extern void SListInsertAfter(SLTNode** pphead, int pos, SLTDataType x);//任意位置删除 extern void SListEraseAfter(SLTNode** pphead, int pos);//打印链表 extern void SListPrint(SLTNode* phead);SList.c#include SList.hSLTNode* BuySListNode(SLTDataType x) {SLTNode* newnode (SLTNode*)malloc(sizeof(SLTNode));if (!newnode){perror(create newnode);exit(-1);}newnode-next NULL;newnode-data x;return newnode; }int SListLength(SLTNode* phead) {SLTNode* tail phead;int count 0;for (count 1; tail-next ! NULL; count){tail tail-next;}return count; }bool CheckEmpty(SLTNode* phead) {return (phead) ? false : true; }void SListPushBack(SLTNode** pphead, SLTDataType x) {if (CheckEmpty(*pphead)){*pphead BuySListNode(x);}else{SLTNode* tail *pphead;while (tail-next){tail tail-next;}tail-next BuySListNode(x);} }void SListPushFront(SLTNode** pphead, SLTDataType x) {SLTNode* newnode BuySListNode(x);newnode-next *pphead;*pphead newnode; }void SListPopBack(SLTNode** pphead) {if (CheckEmpty(*pphead)){printf(SList is empty!\n);return;}//注意仅存有一个节点的情况if (!(*pphead)-next){free(*pphead);*pphead NULL;}//寻找前一个节点else{SLTNode* tail *pphead;while (tail-next-next){tail tail-next;}free(tail-next);tail-next NULL;} }void SListPopFront(SLTNode** pphead) {if (CheckEmpty(*pphead)){printf(SList is empty!\n);return;}SLTNode* ret *pphead;*pphead (*pphead)-next;free(ret); }SLTNode* FindByVal(SLTNode* phead, SLTDataType x) {SLTNode* cur phead;while (cur){if (cur-data x){return cur;}elsecur cur-next;}return NULL; } void SListFindByVal(SLTNode* phead, SLTDataType x) {SLTNode* pos FindByVal(phead, x);if (!pos){printf(Dont find it!\n);return;}//进行多次查找int i 1;while (pos){printf(第%d个pos节点:%p-%d\n, i, pos, pos-data);pos FindByVal(pos-next, x);} }void FindByPos(SLTNode* phead, int pos, SLTNode** pp_aim1, int* p_aim2) {if (pos 0 || pos SListLength(phead)){printf(The position is illegal!\n);}else{SLTNode* tail phead;//注意循环只需进行pos-1所以使用--poswhile (--pos){tail tail-next;}*pp_aim1 tail;*p_aim2 tail-data;} } void SListFindByPos(SLTNode* phead, int pos) {SLTNode* aim1;int aim2 0;FindByPos(phead, pos, aim1, aim2);printf(%d号节点:%p-%d\n, pos, aim1, aim2); }void SListInsertAfter(SLTNode** pphead, int pos, SLTDataType x) {if (pos 0 || pos SListLength(*pphead)){printf(The position is illegal!\n);}else{if (*pphead NULL){*pphead BuySListNode(x);}else if ((*pphead)-next NULL){(*pphead)-next BuySListNode(x);}else{SLTNode* dest *pphead;while (--pos){dest dest-next;}SLTNode* newnode BuySListNode(x);newnode-next dest-next;dest-next newnode;}} }void SListEraseAfter(SLTNode** pphead, int pos) {if (pos 0 || pos SListLength(*pphead)){printf(The position is illegal!\n);}else{SLTNode* prev *pphead;while (--pos){prev prev-next;}SLTNode* afet prev-next-next;free(prev-next);prev-next afet;} }void SListPrint(SLTNode* phead) {if (CheckEmpty(phead)){printf(SList is empty!\n);return;}SLTNode* tail phead;while (!tail NULL){printf(%d-, tail-data);tail tail-next;}printf(NULL\n); }test.c#include SList.hvoid test1() {SLTNode* pList NULL;SListPushFront(pList, 2);SListPushBack(pList, 3);SListPushBack(pList, 4);SListPushBack(pList, 5);SListPushFront(pList, 1);SListPrint(pList); }void test2() {SLTNode* pList NULL;SListPushFront(pList, 2);SListPushBack(pList, 3);SListPushBack(pList, 4);SListPushBack(pList, 5);SListPushFront(pList, 1);SListPrint(pList);SListPopBack(pList);SListPopBack(pList);SListPopBack(pList);SListPopBack(pList);SListPopBack(pList);SListPrint(pList); }void test3() {SLTNode* pList NULL;SListPushFront(pList, 2);SListPushBack(pList, 3);SListPushBack(pList, 4);SListPushBack(pList, 5);SListPushFront(pList, 1);SListPrint(pList);SListPopBack(pList);SListPopBack(pList);SListPopBack(pList);SListPopBack(pList);SListPopBack(pList);SListPrint(pList); }void test4() {SLTNode* pList NULL;SListPushFront(pList, 2);SListPushBack(pList, 3);SListPushBack(pList, 4);SListPushBack(pList, 5);SListPushFront(pList, 1);SListPrint(pList);SListPopFront(pList);SListPopFront(pList);SListPopFront(pList);SListPopFront(pList);SListPrint(pList);SListPopFront(pList);SListPrint(pList); }void test5() {SLTNode* pList NULL;SListPushFront(pList, 3);SListPushBack(pList, 3);SListPushBack(pList, 4);SListPushBack(pList, 3);SListPushFront(pList, 1);SListPrint(pList);SListFindByVal(pList, 3); }void test6() {SLTNode* pList NULL;SListPushFront(pList, 2);SListPushBack(pList, 3);SListPushBack(pList, 4);SListPushBack(pList, 5);SListPushFront(pList, 1);SListPrint(pList);SListFindByPos(pList, 5);}void test7() {SLTNode* pList NULL;SListPushFront(pList, 1);SListPushBack(pList, 3);SListPushBack(pList, 4);SListPushBack(pList, 5);SListPrint(pList);SListInsertAfter(pList, 1, 2);SListPrint(pList); }void test8() {SLTNode* pList NULL;SListPushFront(pList, 2);SListPushBack(pList, 3);SListPushBack(pList, 4);SListPushBack(pList, 5);SListPushFront(pList, 1);SListPrint(pList);SListEraseAfter(pList, 1);SListEraseAfter(pList, 1);SListEraseAfter(pList, 1);SListEraseAfter(pList, 1);SListEraseAfter(pList, 0);SListPrint(pList); }void main() {test1();printf(-------------------------------\n);test2();printf(-------------------------------\n);test3();printf(-------------------------------\n);test4();printf(-------------------------------\n);test5();printf(-------------------------------\n);test6();printf(-------------------------------\n);test7();printf(-------------------------------\n);test8();printf(-------------------------------\n); }
http://www.hkea.cn/news/14531546/

相关文章:

  • 网站工作室和网络公司超凡网络网站
  • 广州营销推广网站网站制作从零开始
  • 企业网站建设规划设计任务书小蜜蜂网站建设
  • 郑州定制网站开发春节期间西安有什么好玩的
  • 一个公司做几个网站制作h5
  • 网站开发哪里便宜wordpress主叶SEO优化
  • 网站建设 上海网站建设qq网页注册入口
  • 建设的网站太卡专门卖电子产品的网站
  • 乐清网站改版公司外贸订单一般在哪个平台接
  • 信息技术九年级上册网站咋做新乡市网站建设电脑培训班
  • 网页给别人做的 网站后续收费吗对电子商务网站建设的理解
  • 网站建设策划书在哪济南兴田德润实惠吗网站美工设计培训学校
  • 网站在线制作软件做礼品贸易好的网站
  • 自己用电脑网站建设河北三河建设局网站
  • 做网站头视频网站维护需要什么
  • 安卓系统优化大师seo顾问什么职位
  • 有没有转门做乐器演奏的网站成都网站建设服务功能
  • 最大的房产网站排名wordpress手机边栏
  • 免费网站设计网站媒体给房开做内容推广
  • 空间资源百度权重优化软件
  • 网站优化用什么软件中国建设银行潍坊市分行官方网站
  • 做盗号网站静态网站设计与制作书籍
  • 网站的色调如何成为网页设计师
  • 安徽网站开发项目湖南长沙有什么好玩的地方
  • 青岛餐饮加盟网站建设不会编程怎样建设网站
  • .net 网站优化wordpress主机cdn
  • 响应式网站开发要注意哪些自己建网站做推广
  • 做外贸那里发广告网站wordpress后台仅显示当前主题
  • spring mvc 做网站佛山专业网站制作公司
  • 珠海网站设计平台聊城哪儿做网站便宜