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

网站后台策划网站开发项目中的rd

网站后台策划,网站开发项目中的rd,艺商网站,牛商网抖音培训目录 一 用队列实现栈 二 用栈实现队列 三 设计循环队列 四 有效的括号 一 用队列实现栈 225. 用队列实现栈 - 力扣#xff08;LeetCode#xff09; typedef int QDataType; typedef struct QueueNode {struct QueueNode* next;QDataType data; }QNode;typedef struct …目录 一 用队列实现栈 二 用栈实现队列  三 设计循环队列  四 有效的括号 一 用队列实现栈 225. 用队列实现栈 - 力扣LeetCode typedef int QDataType; typedef struct QueueNode {struct QueueNode* next;QDataType data; }QNode;typedef struct Queue {QNode* head;QNode* tail;int size; }Que;void QueueInit(Que* pq) {assert(pq);pq-head pq-tail NULL;pq-size 0; }void QueueDestroy(Que* pq) {assert(pq);QNode* cur pq-head;while (cur){QNode* next cur-next;free(cur);cur next;}pq-head pq-tail NULL;pq-size 0; }void QueuePush(Que* pq, QDataType x) {assert(pq);QNode* newnode (QNode*)malloc(sizeof(QNode));if (newnode NULL){perror(malloc fail);exit(-1);}newnode-data x;newnode-next NULL;if (pq-tail NULL){pq-head pq-tail newnode;}else{pq-tail-next newnode;pq-tail newnode;}pq-size; }bool QueueEmpty(Que* pq) {assert(pq);return pq-head NULL; }void QueuePop(Que* pq) {assert(pq);assert(!QueueEmpty(pq));if (pq-head-next NULL){free(pq-head);pq-head pq-tail NULL;}else{QNode* next pq-head-next;free(pq-head);pq-head next;}pq-size--; }QDataType QueueFront(Que* pq) {assert(pq);assert(!QueueEmpty(pq));return pq-head-data; }QDataType QueueBack(Que* pq) {assert(pq);assert(!QueueEmpty(pq));return pq-tail-data; }int QueueSize(Que* pq) {assert(pq);return pq-size; }typedef struct {Que q1;Que q2; } MyStack;MyStack* myStackCreate() {MyStack* pst (MyStack*)malloc(sizeof(MyStack));QueueInit(pst-q1);QueueInit(pst-q2);return pst; }void myStackPush(MyStack* obj, int x) {if (!QueueEmpty(obj-q1)){QueuePush(obj-q1, x);}else{QueuePush(obj-q2, x);} }int myStackPop(MyStack* obj) {Que* empty obj-q1;Que* nonempty obj-q2;if (!QueueEmpty(obj-q1)){nonempty obj-q1;empty obj-q2;}while (QueueSize(nonempty) 1){QueuePush(empty, QueueFront(nonempty));QueuePop(nonempty);}int top QueueFront(nonempty);QueuePop(nonempty);return top; }int myStackTop(MyStack* obj) {if (!QueueEmpty(obj-q1)){return QueueBack(obj-q1);}else{return QueueBack(obj-q2);} }bool myStackEmpty(MyStack* obj) {return QueueEmpty(obj-q1) QueueEmpty(obj-q2); }void myStackFree(MyStack* obj) {QueueDestroy(obj-q1);QueueDestroy(obj-q2);free(obj); }二 用栈实现队列  232. 用栈实现队列 - 力扣LeetCode typedef int STDataType; typedef struct Stack {STDataType* a;int top;int capacity; }ST;void STInit(ST* ps) {assert(ps);ps-a NULL;ps-top 0;ps-capacity 0; }void STDestroy(ST* ps) {assert(ps);free(ps-a);ps-a 0;ps-top ps-capacity 0; }void STPush(ST* ps, STDataType x) {assert(ps);if (ps-top ps-capacity){int newcapacity (ps-capacity 0 ? 4 : ((ps-capacity) * 2));STDataType* tmp (STDataType*)realloc(ps-a, sizeof(STDataType) * newcapacity);if (tmp NULL){perror(realloc fail);exit(-1);}ps-a tmp;ps-capacity newcapacity;}ps-a[ps-top] x;ps-top; }void STPop(ST* ps) {assert(ps);assert(ps-top 0);ps-top--; }STDataType STTop(ST* ps) {assert(ps);assert(ps-top 0);return ps-a[ps-top - 1]; }int STSize(ST* ps) {assert(ps);return ps-top; }bool STEmpty(ST* ps) {assert(ps);return ps-top 0; }typedef struct {ST StackPush;ST StackPop;} MyQueue;MyQueue* myQueueCreate() {MyQueue* pqueue (MyQueue*)malloc(sizeof(MyQueue));STInit(pqueue-StackPush);STInit(pqueue-StackPop);return pqueue; }void myQueuePush(MyQueue* obj, int x) {STPush(obj-StackPush, x); }int myQueuePeek(MyQueue* obj) {if (STEmpty(obj-StackPop)){while (!STEmpty(obj-StackPush)){STPush(obj-StackPop, STTop(obj-StackPush));STPop(obj-StackPush);}}return STTop(obj-StackPop);}int myQueuePop(MyQueue* obj) {int front myQueuePeek(obj);STPop(obj-StackPop);return front; }bool myQueueEmpty(MyQueue* obj) {return STEmpty(obj-StackPush) STEmpty(obj-StackPop); }void myQueueFree(MyQueue* obj) {STDestroy(obj-StackPush);STDestroy(obj-StackPop);free(obj); }三 设计循环队列  622. 设计循环队列 - 力扣LeetCode typedef struct {int* a;int front;int rear;int k; } MyCircularQueue;MyCircularQueue* myCircularQueueCreate(int k) {MyCircularQueue* obj (MyCircularQueue*)malloc(sizeof(MyCircularQueue));obj-a (int*)malloc(sizeof(int) * (k 1));//多开一个空间obj-front obj-rear 0;obj-k k;return obj; }bool myCircularQueueIsEmpty(MyCircularQueue* obj) {return obj-front obj-rear; }bool myCircularQueueIsFull(MyCircularQueue* obj) {return (obj-rear 1) % (obj-k 1) obj-front; }bool myCircularQueueEnQueue(MyCircularQueue* obj, int value) {if (myCircularQueueIsFull(obj)){return false;}obj-a[obj-rear] value;obj-rear;obj-rear % (obj-k 1);return true; }bool myCircularQueueDeQueue(MyCircularQueue* obj) {if (myCircularQueueIsEmpty(obj)){return false;}obj-front;obj-front % (obj-k 1);return true; }int myCircularQueueFront(MyCircularQueue* obj) {if (myCircularQueueIsEmpty(obj)){return -1;}else{return obj-a[obj-front];}}int myCircularQueueRear(MyCircularQueue* obj) {if (myCircularQueueIsEmpty(obj)){return -1;}else {return obj-a[(obj-rear obj-k) % (obj-k 1)];}}void myCircularQueueFree(MyCircularQueue* obj) {free(obj-a);free(obj); } 四 有效的括号 20. 有效的括号 - 力扣LeetCode typedef char STDataType; typedef struct Stack {STDataType* a;int top;int capacity; }ST;void STInit(ST* ps) {assert(ps);ps-a NULL;ps-top ps-capacity 0; }void STDestroy(ST* ps) {assert(ps);free(ps-a);ps-a NULL;ps-top ps-capacity 0; }void STPush(ST* ps, STDataType x) {assert(ps);if (ps-top ps-capacity){int newcapacity (ps-capacity 0 ? 4 : ps-capacity * 2);STDataType* tmp (STDataType*)realloc(ps-a, sizeof(STDataType) * newcapacity);if (tmp NULL){perror(realloc fail);exit(-1);}ps-a tmp;ps-capacity newcapacity;}ps-a[ps-top] x;ps-top; }void STPop(ST* ps) {assert(ps);assert(ps-top 0);ps-top--; }STDataType STTop(ST* ps) {assert(ps);assert(ps-top 0);return ps-a[ps-top - 1]; }int STSize(ST* ps) {assert(ps);return ps-top; }bool STEmpty(ST* ps) {assert(ps);return ps-top 0; }bool isValid(char* s) {ST st;STInit(st);while (*s){if (*s ( || *s { || *s [){STPush(st, *s);}else{if (STEmpty(st)){STDestroy(st);return false;}char topval STTop(st);STPop(st);if ((*s ] topval ! [) || (*s ) topval ! () || (*s } topval ! {)){STDestroy(st);return false;}}s;}bool ret STEmpty(st);STDestroy(st);return ret; }
http://www.w-s-a.com/news/115806/

相关文章:

  • 毕业设计做网站好的想法开发网站代码量
  • 西宁网站建设排名wordpress的站点地址如何配置
  • 医院网站建设 价格app和网站开发的成本
  • 常见的网站开发工具山东建设厅官方网站李兴军
  • 二级院系网站建设情况做网站域名是什么意思
  • 网站开发双语辽宁省建设厅网站怎样下载表格
  • 网站后台密码怎么修改百度查重免费入口
  • 衡阳网站页面设计公司绍兴网站设计
  • 青岛手机建站多少钱做图表的网站 免费
  • 如何去建立和设计一个公司网站开封建设教育协会网站
  • 南充市住房和城乡建设局考试网站wordpress 下载模板站
  • 有没有单纯做旅游攻略的网站保定建站方案
  • 2017网站建设报价方案2022年企业所得税税率表一览
  • 可以做婚礼视频的网站有哪些工程公司管理制度
  • 做农产品网站需要做的准备中文手机网站设计案例
  • 福州做网站软件seo搜索优化专员招聘
  • 建站技术博客wordpress响应时间
  • 农业网站模板WordPress安徽省建设工程造价管理协会网站
  • 网站后台策划书破解版手游app平台
  • 宿迁网站建设介绍公司wordpress 文章 分类 页面
  • 建设通同类网站网站设计公司种类
  • 台州专业做网站网站可以个人做吗
  • 个人logo在线生成免费乐陵德州seo公司
  • 网站回答问题app怎么做专业定制网红柴火灶
  • 网站做的最好的公司行业网址大全
  • 内网怎么做网站服务器seo统计
  • 丽水市企业网站建设 微信营销 影视拍摄计算机专业吃香吗
  • 龙岗做网站公司哪家好找到做网站的公司
  • 网站图片alt属性wordpress 自定义栏目 调用
  • 怎样建网站最快广州网站建设工程