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

免费自助站制作在线wordpress 积分

免费自助站制作在线,wordpress 积分,c2c网站的特点,做网站 简单外包目录 顺序表#xff1a; 链表#xff1a; 栈#xff1a; 队列#xff1a; 我想在之后的大学数据结构课上需要自己写来做题#xff0c;但每次都自己写#xff0c;那太麻烦了#xff0c;所以我就将这个博客来把所有的C语言的数据结构弄上去#xff0c; 问我为什么不…目录 顺序表 链表 栈 队列 我想在之后的大学数据结构课上需要自己写来做题但每次都自己写那太麻烦了所以我就将这个博客来把所有的C语言的数据结构弄上去 问我为什么不用GitHub虽说也托管上去了哈哈机房访问的GitHub太慢了 顺序表 头文件 #pragma once #define _CRT_SECURE_NO_WARNINGS 1 #includestdio.h #includestdlib.h #includeassert.h #includestdbool.h// 队列先进先出typedef int QUDataType;typedef struct QueueNode {struct QueueNode* next;QUDataType x; }QueueNode;typedef struct QUEUE {QueueNode* head;QueueNode* tail; }Queue;//初始化 void QueueInit(Queue* pq);//入队列 void QueuePush(Queue* pq,QUDataType x);//出队列 void QueuePop(Queue* pq);//取头数据 QUDataType QueueFront(Queue* pq);//取尾数据 QUDataType QueueBack(Queue* pq);//有几个数据int QueueSize(Queue* pq);//是否为空bool QueueEmpty(Queue* pq);//打印 void Print(Queue* pq); 函数文件 #define _CRT_SECURE_NO_WARNINGS 1 #includemain.hvoid Checkcapacity(SL* pc) {if (pc-size pc-capacity){int newcapacity pc-capacity 0 ? 4 : pc-capacity * 2;SLDataType* str (SLDataType*)realloc(pc-a, newcapacity * sizeof(SLDataType));if (str NULL){perror(realloc);exit(-1);}} }void print(SL* pc) {int i 0;for (i 0; i pc-size; i){printf(%d , pc-a[i]);} }//回收空间 void SeqlistDestory(SL* pc) {free(pc-a);pc-a NULL;pc-capacity pc-size 0; }void SeqListInit(SL* pc) {pc-a NULL;pc-size 0;pc-capacity 0; }void SeqListPushback(SL* pc, SLDataType x) {//如果没有空间或根本没有就增容if (pc-size pc-capacity){int newcapacity pc-capacity 0 ? 4 : pc-capacity * 2;SLDataType* str (SLDataType*)realloc(pc-a,newcapacity*sizeof(SLDataType));if (str NULL){perror(realloc);exit(-1);}pc-a str;str NULL;pc-capacity newcapacity;}pc-a[pc-size] x;pc-size; }void SeqlistPopback(SL* pc) {if (pc-size 0){printf(没有了喵~\n);return;}pc-a[pc-size - 1] 0;pc-size--; }void SeqlistPushfront(SL* pc, SLDataType x) {if (pc-size pc-capacity){int newcapacity pc-capacity 0 ? 4 : pc-capacity * 2;SLDataType* str (SLDataType*)realloc(pc-a, newcapacity * sizeof(SLDataType));if (str NULL){perror(realloc);exit(-1);}pc-a str;str NULL;pc-capacity newcapacity;}pc-size 1;for (int i pc-size; i0; i--){pc-a[i1] pc-a[i];}pc-a[0]x; }void SeqlistPopfront(SL* pc) {if (pc-size 0){printf(没u删除的元素喵~\n);}int i 1;for (i i; i pc-size1; i){pc-a[i - 1] pc-a[i];}pc-size - 1; }//插入数字 void Seqlistinsert(SL* pc, int pos, SLDataType x) {Checkcapacity(pc);pc-size 1;int ipos;for (i pos; i pc-size; i){pc-a[i] pc-a[i - 1];}pc-a[pos - 1] x; }//查找数字() int Seqlistfind_bydata(SL* pc, SLDataType x) {int i 0;for (i; i pc-size; i){if (pc-a[i] x){printf(返回第一个下标\n);return i;}}printf(找不到\n);return -1; }//删除指定数字 void Seqlistdelet(SL* pc, SLDataType x) {int i 0;for (i 0; i pc-size; i){if (x pc-a[i]){for (i; i pc-size; i){pc-a[i] pc-a[i 1];}pc-size--;break;}}printf(没这个数字哦\n);return; } 链表 头文件 #pragma once #define _CRT_SECURE_NO_WARNINGS 1 #includestdio.h #includestdlib.h//单链表的英文 Single linked listtypedef int SLLdatatype;typedef struct SListNode {SLLdatatype data;struct SListNode*next; }SLL;//打印 void SLLprint(SLL* phead);//尾部存储 void SLLpushback(SLL**phead,SLLdatatype x);//头部存储 void SLLpushfront(SLL** phead, SLLdatatype x);void SLLpushfront2(SLL** phead, SLLdatatype x);//尾部删除 void SLLpopback(SLL** phead);//头部删除 void SLLpopfront(SLL** phead);//查找 void SLL_find_print(SLL* phead, SLLdatatype x);//查下标 SLL* SLL_findpos(SLL* phead, SLLdatatype x);// 指定位置插入 void SLL_inset(SLL** phead, SLL* pos, SLLdatatype x);//指定位置删除 void SLL_pos_del(SLL** phead, SLL* pos);//销毁链表 void SLL_destory(SLL* *phead);函数文件 #define _CRT_SECURE_NO_WARNINGS 1 #includemain.hSLL* creatnode( SLLdatatype x) {SLL* newnode (SLL*)malloc(sizeof(SLL));if (newnode NULL){perror(malloc);exit(-1);}newnode-data x;newnode-next NULL;return newnode; }//打印 void SLLprint(SLL* phead) {/*SLL* cur phead;*/while (phead ! NULL){printf(%d , phead-data);phead phead-next;}printf(-NULL\n); }void SLLpushback(SLL**phead,SLLdatatype x) {SLL* newnode (SLL*)malloc(sizeof(SLL));newnode-data x;newnode-next NULL;if (*phead NULL){*phead newnode;}else{SLL* tail *phead;while (tail-next ! NULL){tail tail-next;}tail-next newnode;} }void SLLpushfront(SLL** phead, SLLdatatype x) {SLL* newnode (SLL*)malloc(sizeof(SLL));newnode-data x;newnode-next NULL;if (phead NULL){*phead newnode;}else{newnode-next *phead;*phead newnode;}}void SLLpushfront2(SLL** phead, SLLdatatype x) {SLL* newnode creatnode(x);newnode-next *phead;*phead newnode; }//尾部删除 void SLLpopback(SLL** phead){SLL*tail *phead;SLL* str NULL;if (*pheadNULL){return ;}if (tail-next NULL){free(tail);*phead NULL;}else{while (tail-next!NULL){str tail;tail tail-next;}free(tail);tail NULL;str-next NULL;} }//头部删除 void SLLpopfront(SLL** phead) {if (*phead NULL){return;}if ((*phead)-next NULL){*phead NULL;}else{SLL* front *phead;(*phead)(*phead)-next;free(front);front NULL;} }//找加打印 void SLL_find_print(SLL* phead, SLLdatatype x) {if (phead NULL){return;}while (phead-data!x){if (phead-next NULL){break;}phead phead-next;}if (phead-next NULL){printf(找不到喵~\n);}else{printf(%d\n, phead-data);} }//查下标 SLL* SLL_findpos(SLL* phead, SLLdatatype x) {if (phead NULL){return NULL;}else{while (phead){if (phead-data x){return phead;}phead phead-next;}}printf(找不到\n);return NULL; }// 指定位置插入 void SLL_inset(SLL** phead, SLL* pos, SLLdatatype x) {if (*phead NULL){return;}else{SLL* find *phead;while (find){if (find-next pos){SLL* newnode creatnode(x);newnode-next find-next;find-next newnode;return;}find find-next;}} }//指定位置删除 void SLL_pos_del(SLL** phead, SLL* pos) {if (*phead NULL){return;}else{SLL* find *phead;SLL* findpos NULL;while (find){if (find-next pos){findpos find-next;find-next findpos-next;free(findpos);findpos NULL;return;}find find-next;}}}//销毁链表 void SLL_destory(SLL** phead) {if (*phead NULL){return;}else{ while ((*phead)-next!NULL){SLL* tailpos *phead;SLL* tail NULL;while (tailpos-next ! NULL){tail tailpos;tailpos tailpos-next;}free(tailpos);tail-next NULL;tailpos NULL;}free(*phead);*phead NULL;} } 栈 头文件 #pragma once #define _CRT_SECURE_NO_WARNINGS 1#includestdio.h #includestdlib.h #includeassert.h #includestdbool.htypedef int STDataType;typedef struct Stack {STDataType* a;int top;int capacity; }ST;//初始化栈 void StackIint(ST* ps);//销毁栈 void Stackdestory(ST* pc);//push void StackPush(ST* ps, STDataType x);//pop void StackPop(ST* ps);//取栈顶数据 STDataType Stacktop(ST* ps);//有多少数据 int StackSize(ST* ps);//判断是否为空 bool StackEmpty(ST* ps);int minStackGetMin(ST* obj); 函数 #define _CRT_SECURE_NO_WARNINGS 1 #includemain.h//初始化单链表 void StackIint(ST* ps) {assert(ps);ps-a NULL;ps-capacity 0;ps-top 0; }//销毁栈 void Stackdestory(ST* pc) {assert(pc);free(pc-a);pc-a NULL;pc-capacity pc-top 0; }//push void StackPush(ST* ps, STDataType x) {assert(ps);if (ps-capacity ps-top){ps-capacity ps-capacity 0 ? 4 : 2 * ps-capacity;STDataType* temp (STDataType*)realloc(ps-a, sizeof(STDataType) * ps-capacity);if (temp NULL){printf(realloc fail\n);exit(-1);}ps-a temp;}ps-a[ps-top] x;ps-top 1;}int minStackGetMin(ST* obj) {int i 0;int min obj-a[i];for (i 1; iobj-top; i){if (obj-a[i] min){min obj-a[i];}}return min; }//pop void StackPop(ST* ps) {assert(ps-top 0);ps-top--; }//取栈顶数据 STDataType Stacktop(ST* ps) {assert(!StackEmpty(ps));return ps-a[ps-top - 1]; }//有多少数据 int StackSize(ST* ps) {assert(!StackEmpty(ps));return ps-top; } //判断是否为空 bool StackEmpty(ST* ps) {return ps-top 0; }队列 头文件 #pragma once #define _CRT_SECURE_NO_WARNINGS 1 #includestdio.h #includestdlib.h #includeassert.h #includestdbool.h// 队列先进先出typedef int QUDataType;typedef struct QueueNode {struct QueueNode* next;QUDataType x; }QueueNode;typedef struct QUEUE {QueueNode* head;QueueNode* tail; }Queue;//初始化 void QueueInit(Queue* pq);//入队列 void QueuePush(Queue* pq,QUDataType x);//出队列 void QueuePop(Queue* pq);//取头数据 QUDataType QueueFront(Queue* pq);//取尾数据 QUDataType QueueBack(Queue* pq);//有几个数据int QueueSize(Queue* pq);//是否为空bool QueueEmpty(Queue* pq);//打印 void Print(Queue* pq); 函数 #define _CRT_SECURE_NO_WARNINGS 1 #includemain.h//初始化 void QueueInit(Queue* pq) {assert(pq);pq-head NULL;pq-tail NULL; }void QueueDestory(Queue* pq) {assert(pq);QueueNode* cur pq-head;while (cur!NULL){QueueNode* next cur-next;free(cur);cur next;}pq-head NULL;pq-tail NULL;}//入队列 void QueuePush(Queue* pq, QUDataType x) {assert(pq);if (pq-head NULL pq-tail NULL){QueueNode* newnode (QueueNode*)malloc(sizeof(QueueNode));newnode-x x;newnode-next NULL;pq-headnewnode;pq-tailnewnode;}else{QueueNode* newnode (QueueNode*)malloc(sizeof(QueueNode));newnode-x x;newnode-next NULL;QueueNode* tail1 NULL;tail1 pq-tail;tail1-next newnode;pq-tail newnode;} }//出队列 void QueuePop(Queue* pq) {assert(pq);if (pq-head NULL){exit(-1);}QueueNode* head1 pq-head-next;free(pq-head);pq-head head1;if (pq-head NULL){pq-head pq-tail NULL;} }//取头数据 QUDataType QueueFront(Queue* pq) {assert(pq);assert(pq-head);return pq-head-x; }//取尾数据 QUDataType QueueBack(Queue* pq) {assert(pq);assert(pq-head);return pq-tail-x; }//有几个数据int QueueSize(Queue* pq) {assert(pq);int count 0;QueueNode*pos pq-head;while (pos ! NULL){count 1;pos pos-next;}return count; }//是否为空 bool QueueEmpty(Queue* pq) {assert(pq);if (pq-head){return false;}return true; }//打印 void Print(Queue* pq) {assert(pq);assert(pq-head);QueueNode* pos pq-head;while (pos ! NULL){printf(%d , pos-x);pos pos-next;}printf(\n); } typedef struct {Queue* q1;Queue* q2; } MyStack;MyStack* myStackCreate() {MyStack* st (MyStack*)malloc(sizeof(MyStack));st-q1 (QUEUE*)malloc(sizeof(QUEUE));st-q2 (QUEUE*)malloc(sizeof(QUEUE));return st; }void myStackPush(MyStack* obj, int x) {if (!QueueEmpty(obj-q1)){QueuePush(obj-q1, x);}else{QueuePush(obj-q2, x);} }int myStackPop(MyStack* obj) {Queue* empty obj-q1;Queue* noempty obj-q2;if (!QueueEmpty(obj-q1)){empty obj-q2;noempty obj-q1;}int top QueueBack(noempty);while (QueueSize(noempty) 0){QueuePush(empty, QueueFront(noempty));QueuePop(noempty);}return top;}int myStackTop(MyStack* obj) {if (!QueueEmpty(obj-q1)){return QueueBack(obj-q1);}return QueueBack(obj-q2); }bool myStackEmpty(MyStack* obj) {if (QueueEmpty(obj-q1) || QueueEmpty(obj-q2)){return false;}return true;}void myStackFree(MyStack* obj) {free(obj-q1);free(obj-q2);free(obj); }
http://www.hkea.cn/news/14490410/

相关文章:

  • 帮别人建网站赚钱吗网站首页制作模板
  • 购物网站模块是什么意思网站开发全程实例
  • 朔州建设机械网站动画设计专业好的学校
  • 建筑工程网官方网站wordpress自动评论插件
  • 建造电商网站个人网站设计怎么做
  • 贵州网站开发哪家便宜建设网站分析
  • 外贸网站设计注意事项网页设计代码案例
  • 常州手机网站开发怎么自己做网站服务器
  • 公司做网站的费用记什么科目上海今天最新发布会
  • 网站的联系我们怎么做wordpress 如何升级
  • 网站开发技术背景介绍房产采集网站源代码
  • 广州建网站价格郑州网站建设 云极
  • 英语门户网站织梦源码电脑上怎么运行wordpress
  • 网站推广需求要素做网站 公司 个体
  • 万网公司注册网站邢台企业建站
  • 二级网站内容建设要求百度一键安装
  • 优秀网站建设网页廊坊做网站公司
  • 化工行业网站建设嵌入式开发工程师前景
  • 深圳雅迅公司网站建设专业做美食视频的网站
  • 做网站的公司找客户wordpress淘宝客自动采集
  • 搜索动图素材的网站公司网站运营注意事项
  • 信誉比较好的商家可做网站dw怎么做打开网站跳出提示
  • 淮南建设公司网站怎么做网站需求分析
  • 如何找网站建设客户电影网站网页设计实训报告
  • ppt做视频模板下载网站有哪些内容广西seo搜索引擎优化
  • 自己开发网站要多少钱wordpress宾馆
  • 北京哪个公司做网站做蛋糕的网站
  • 怎样做网站亮照亮标一个公司能备案几个网站
  • wordpress搭建网站东莞响应式网站建设定制
  • 做网站订金是多少微信公众平台入口