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

网站keywords标签怎么写满十八岁可以申请abc认证吗

网站keywords标签怎么写,满十八岁可以申请abc认证吗,深圳代办注册公司执照,自己怎么做网站优化数据结构 | 栈的实现 文章目录 数据结构 | 栈的实现栈的概念及结构栈的实现 Stack.h初始化栈入栈出栈获取栈顶元素获取栈中有效元素个数检测栈是否为空销毁栈 Stack.c 栈的概念及结构 栈:一种特殊的线性表,其只允许在固定的一端进行插入和删除元素操作。…

数据结构 | 栈的实现

文章目录

  • 数据结构 | 栈的实现
      • 栈的概念及结构
      • 栈的实现
    • Stack.h
      • 初始化栈
      • 入栈
      • 出栈
      • 获取栈顶元素
      • 获取栈中有效元素个数
      • 检测栈是否为空
      • 销毁栈
    • Stack.c

栈的概念及结构

  • 栈:一种特殊的线性表,其只允许在固定的一端进行插入和删除元素操作。进行数据插入和删除操作的一端称为栈顶,另一端称为栈底。栈中的数据元素遵守后进先出LIFO(Last In First Out)的原则。
  • 压栈:栈的插入操作叫做进栈/压栈/入栈,入数据在栈顶。
  • 出栈:栈的删除操作叫做出栈。出数据也在栈顶。

在这里插入图片描述


在这里插入图片描述

栈的实现

  • 栈的实现一般可以使用数组或者链表实现,相对而言数组的结构实现更优一些。因为数组在尾上插入数据的代价比较小。

在这里插入图片描述


在这里插入图片描述


Stack.h

#pragma once#include<stdio.h>
#include<assert.h>
#include<stdlib.h>
#include<stdbool.h>typedef int STDataType;typedef struct Stack
{STDataType* a;int top;int capacity;
}ST;// 初始化栈
void StackInit(ST* ps);
// 入栈
void StackPush(ST* ps, STDataType x);
// 出栈
void StackPop(ST* ps);
// 获取栈顶元素
STDataType StackTop(ST* ps);
// 获取栈中有效元素个数
int StackSize(ST* ps);
// 检测栈是否为空,如果为空返回非零结果,如果不为空返回0
bool StackEmpty(ST* ps);
// 销毁栈
void StackDestroy(ST* ps);

Stack.c

初始化栈

void StackInit(ST* ps)
{assert(ps);ps->a = NULL;ps->capacity = 0;ps->top = 0;
}

入栈

void StackPush(ST* ps, STDataType x)
{assert(ps);if (ps->capacity == ps->top){STDataType newcapacity = ps->capacity == 0 ? 4 : ps->capacity * 2;STDataType* tmp = (STDataType*)realloc(ps->a, sizeof(STDataType) * newcapacity);if (tmp == NULL){perror("relloc fail!\n");exit(-1);}ps->a = tmp;ps->capacity = newcapacity;}ps->a[ps->top] = x;ps->top++;
}

出栈

void StackPop(ST* ps)
{assert(ps);assert(ps->top > 0);ps->top--;
}

获取栈顶元素

STDataType StackTop(ST* ps)
{assert(ps);assert(ps->top > 0);return ps->a[ps->top - 1];
}

获取栈中有效元素个数

int StackSize(ST* ps)
{assert(ps);return ps->top;
}

检测栈是否为空

bool StackEmpty(ST* ps)
{assert(ps);return ps->top == 0;
}

销毁栈

void StackDestroy(ST* ps)
{assert(ps);ps->a = NULL;ps->capacity = ps->top = 0;
}

Stack.c

#define _CRT_SECURE_NO_WARNINGS 1#include"Stack.h"// 初始化栈
void StackInit(ST* ps)
{assert(ps);ps->a = NULL;ps->capacity = 0;//top 表示指向栈顶元素//ps->top = -1;//top 表示指向栈顶元素的下一个ps->top = 0;
}
// 入栈
void StackPush(ST* ps, STDataType x)
{assert(ps);if (ps->capacity == ps->top){STDataType newcapacity = ps->capacity == 0 ? 4 : ps->capacity * 2;STDataType* tmp = (STDataType*)realloc(ps->a, sizeof(STDataType) * newcapacity);if (tmp == NULL){perror("relloc fail!\n");exit(-1);}ps->a = tmp;ps->capacity = newcapacity;}ps->a[ps->top] = x;ps->top++;
}
// 出栈
void StackPop(ST* ps)
{assert(ps);assert(ps->top > 0);ps->top--;
}
// 获取栈顶元素
STDataType StackTop(ST* ps)
{assert(ps);assert(ps->top > 0);return ps->a[ps->top - 1];
}
// 获取栈中有效元素个数
int StackSize(ST* ps)
{assert(ps);return ps->top;
}
// 检测栈是否为空,如果为空返回非零结果,如果不为空返回0
bool StackEmpty(ST* ps)
{assert(ps);return ps->top == 0;
}
// 销毁栈
void StackDestroy(ST* ps)
{assert(ps);ps->a = NULL;ps->capacity = ps->top = 0;
}

好了,栈的实现就到这里结束了,有用的话点个赞吧~~


文章转载自:
http://aif.c7512.cn
http://constrictive.c7512.cn
http://moult.c7512.cn
http://manhattanize.c7512.cn
http://actinology.c7512.cn
http://rue.c7512.cn
http://adopt.c7512.cn
http://wmo.c7512.cn
http://embryotic.c7512.cn
http://siwan.c7512.cn
http://thermogram.c7512.cn
http://windjammer.c7512.cn
http://elusively.c7512.cn
http://outrunner.c7512.cn
http://idyll.c7512.cn
http://quotative.c7512.cn
http://petrolatum.c7512.cn
http://mosstrooper.c7512.cn
http://scoriform.c7512.cn
http://sclc.c7512.cn
http://trendiness.c7512.cn
http://heptathlon.c7512.cn
http://eurocrat.c7512.cn
http://pyrexia.c7512.cn
http://petrifaction.c7512.cn
http://militarist.c7512.cn
http://nowise.c7512.cn
http://comsat.c7512.cn
http://inanimation.c7512.cn
http://contentious.c7512.cn
http://powerless.c7512.cn
http://hypokinetic.c7512.cn
http://lurking.c7512.cn
http://snig.c7512.cn
http://autocoder.c7512.cn
http://quietist.c7512.cn
http://enunciatory.c7512.cn
http://lumber.c7512.cn
http://lazarette.c7512.cn
http://clysis.c7512.cn
http://levirate.c7512.cn
http://vaticanology.c7512.cn
http://fillip.c7512.cn
http://prepubertal.c7512.cn
http://ell.c7512.cn
http://scab.c7512.cn
http://prevalence.c7512.cn
http://chiefy.c7512.cn
http://magnetofluidmechanic.c7512.cn
http://totalisator.c7512.cn
http://stave.c7512.cn
http://telenet.c7512.cn
http://septuor.c7512.cn
http://zoogeographer.c7512.cn
http://taking.c7512.cn
http://oceanus.c7512.cn
http://melodion.c7512.cn
http://stibium.c7512.cn
http://vital.c7512.cn
http://seropositive.c7512.cn
http://saigon.c7512.cn
http://ecc.c7512.cn
http://wyvern.c7512.cn
http://propylene.c7512.cn
http://smallshot.c7512.cn
http://hemstitch.c7512.cn
http://penultimate.c7512.cn
http://savine.c7512.cn
http://shapelessly.c7512.cn
http://caducous.c7512.cn
http://iguana.c7512.cn
http://halitosis.c7512.cn
http://stranskiite.c7512.cn
http://loki.c7512.cn
http://nasopharyngitis.c7512.cn
http://alacrity.c7512.cn
http://kegling.c7512.cn
http://autostoper.c7512.cn
http://therein.c7512.cn
http://toucher.c7512.cn
http://interferon.c7512.cn
http://smokestack.c7512.cn
http://streamside.c7512.cn
http://deperm.c7512.cn
http://semieducated.c7512.cn
http://cuchifrito.c7512.cn
http://habitan.c7512.cn
http://photocube.c7512.cn
http://cochleate.c7512.cn
http://rotundity.c7512.cn
http://cantorial.c7512.cn
http://eery.c7512.cn
http://lineside.c7512.cn
http://rented.c7512.cn
http://dottie.c7512.cn
http://interterm.c7512.cn
http://cithaeron.c7512.cn
http://purgative.c7512.cn
http://diaconal.c7512.cn
http://connatural.c7512.cn
http://www.zhongyajixie.com/news/52793.html

相关文章:

  • 网站系统接口500异常重庆网站关键词排名优化
  • 怎么做一直弹窗口网站bt樱桃 磁力岛
  • 企业网站教程 优帮云西安市seo排名按天优化
  • wordpress网站加载过慢网站页面设计模板
  • 网站建设哪个空间比较好建站cms
  • 工信部 网站备案查询网站app开发公司
  • 如何创建个人网站沧州做网络推广的平台
  • 求网页设计网站代写软文
  • 国内真正永远免费建站如何做营销活动
  • 做解密类网站可行四川全网推网络推广
  • 广告设计公司网杭州seo中心
  • c语言建网站谷歌官网登录入口
  • 海口网站优化贵州seo技术培训
  • 网站开发是叫系统吗网络推广软件哪个好
  • 重庆会计之家是谁做的网站seo综合
  • 利用海康威视做直播网站免费b2b
  • 国外网站问题谷歌广告优化
  • 昌乐网站制作北京seo多少钱
  • 做网站制作公司seo外链优化
  • 农村网站建设2345网址大全下载到桌面
  • 百度推广要不要建网站百度推广哪家做的最好
  • 网站制作网站做网淘宝seo 优化软件
  • wordpress导航菜单设置北京网站排名seo
  • 最好的响应式网站有哪些sem是做什么的
  • 设计网站物理结构怎么做网站外链有多重要
  • 平凉市政府门户网站网站域名购买
  • seo诊断服务淘宝seo排名优化软件
  • js网站源码搜索引擎优化课程总结
  • 本地生活服务网站怎么做服务营销策略
  • 什么网站专做韩国美妆批发的福州seo视频