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

高端大气网站案例怎么做私人网站

高端大气网站案例,怎么做私人网站,html5博客网站源码,菜鸟制作个人网站网页实例栈的概念以及栈的实现 栈是一种只允许在一端进行插入和删除的线性表 空栈:没有任何元素 入栈:插入元素 出栈:删除元素 栈本身就是一个线性表,我们可以写一个足够大的数组来实现栈 除此之外,我们还需要变量n来记录…

栈的概念以及栈的实现

栈是一种只允许在一端进行插入和删除的线性表

空栈:没有任何元素

入栈:插入元素

出栈:删除元素

栈本身就是一个线性表,我们可以写一个足够大的数组来实现栈

除此之外,我们还需要变量n来记录栈顶元素和栈的元素个数

我们来实现一下栈

#include <iostream>
using namespace std;
const int N = 1e6;
int st[N];
int n = 0;
void push(int x)
{st[++n] = x;
}
void pop()
{--n;
}
int top()
{return st[n];
}
int size()
{return n;
}
bool empty()
{return n == 0;
}int main()
{for (int i = 0; i < 10; i++){push(i);}while (size()){cout << top() << " ";pop();}}

上述代码就是我们栈的实现,我们栈的元素是从数组下标为1开始的,如果栈顶下标是0的话就是空栈

我们入栈是0,1,2,3,4,5,6,7,8,9

出栈的时候就是从9开始弹出

STL 的stack

除了我们的静态的栈,我们stl库里面还有一个现成的栈,叫stack,它的创建和vector实际上是差不多的

我们来测试一下stack

#include <iostream>
#include <stack>
using namespace std;
const int N = 1e6;stack <int> st;
int main()
{for(int i =0 ;i<10;i++){st.push(i);}while(!st.empty()){cout << st.top() << " ";st.pop();}}

栈和stack的算法题

栈的模板题

这道题我们有两个需要注意的点,第一个数据范围

int的数据范围是-2的31次方到2的31次方-1

unsigned int是0到 2的32次方-1

long long的范围是2的63次方-1

unsigned long long的范围是2的64次方减1

所以我们栈的数据类型应该是unsigned longlong

第二点就是,我们每组数据是隔离的,互不影响的,所以我们要处理脏数据,再每次处理完一组数据之后,要清空我们的栈

这是我们ac的代码

#include <iostream>
using namespace std;
const int N = 1e6+10;
typedef unsigned long long LL;
LL st[N];
int top;
int main()
{int t;int n;cin >> t;while(t--){top = 0;int n;cin >> n;while(n--){string op;cin >> op;if(op == "push"){LL x;cin >> x;st[++top] =x;}else if(op == "pop"){if(top == 0)cout << "Empty" << endl;elsetop--;}else if(op == "query"){if(top == 0){cout <<"Anguei!" << endl;}elsecout << st[top] << endl;}else{cout << top << endl;}}}return 0;
}

栈的算法题之有效的括号

这道题我们用stack来解决一下

如果是左括号,我们入栈,如果是右括号,我们进行匹配,匹配成功出栈,匹配如果不成功那我们就返回false,最后我们还要查看一下栈是不是空,如果不是空,还是false

class Solution {
public:bool isValid(string s) {stack <char> a;for(auto e:s){if (e == '(' or e == '[' or e=='{'){a.push(e);}if(e == ')' or e == ']' or e== '}'){if(empty(a))return false;if((e == ')' && a.top() != '(') or (e == '}' && a.top() != '{') or(e == ']' && a.top() != '[')) return false;a.pop();}}return empty(a);}
};

小tips :我们要注意,右括号匹配的时候,如果栈空了,也是要返回false的,如果没有判空这一个条件,我们取top就会越界。


文章转载自:
http://dinncoxanthippe.wbqt.cn
http://dinncoundercliff.wbqt.cn
http://dinncocur.wbqt.cn
http://dinncoboxkeeper.wbqt.cn
http://dinncomysticlsm.wbqt.cn
http://dinncofeverous.wbqt.cn
http://dinnconeuroglia.wbqt.cn
http://dinncocoolgardie.wbqt.cn
http://dinncoknurr.wbqt.cn
http://dinncotrapball.wbqt.cn
http://dinncohomomorphy.wbqt.cn
http://dinncobind.wbqt.cn
http://dinncobang.wbqt.cn
http://dinncofullback.wbqt.cn
http://dinncokifi.wbqt.cn
http://dinncolymphoblastic.wbqt.cn
http://dinncoxvi.wbqt.cn
http://dinncoligament.wbqt.cn
http://dinncodromomania.wbqt.cn
http://dinncocyclamate.wbqt.cn
http://dinncounisonous.wbqt.cn
http://dinncofluorin.wbqt.cn
http://dinncosukkah.wbqt.cn
http://dinncochelicera.wbqt.cn
http://dinncomicroclimate.wbqt.cn
http://dinncostrobotron.wbqt.cn
http://dinncoutterly.wbqt.cn
http://dinncolayelder.wbqt.cn
http://dinncoalgolagnia.wbqt.cn
http://dinncotachinid.wbqt.cn
http://dinncotortoiseshell.wbqt.cn
http://dinncoaspergill.wbqt.cn
http://dinncoassuror.wbqt.cn
http://dinncogourdful.wbqt.cn
http://dinncoalanine.wbqt.cn
http://dinncojervis.wbqt.cn
http://dinncolawes.wbqt.cn
http://dinncopresumable.wbqt.cn
http://dinncoprebendal.wbqt.cn
http://dinncoashore.wbqt.cn
http://dinncooverstrung.wbqt.cn
http://dinncokootenai.wbqt.cn
http://dinncosubstantialist.wbqt.cn
http://dinncomottled.wbqt.cn
http://dinncowham.wbqt.cn
http://dinncoirised.wbqt.cn
http://dinncofederalese.wbqt.cn
http://dinncocounselor.wbqt.cn
http://dinncoocciput.wbqt.cn
http://dinncoexploiture.wbqt.cn
http://dinncoimmensely.wbqt.cn
http://dinncocyme.wbqt.cn
http://dinncotopographic.wbqt.cn
http://dinncomisdate.wbqt.cn
http://dinncoundersecretary.wbqt.cn
http://dinncoearwitness.wbqt.cn
http://dinncoventriloquial.wbqt.cn
http://dinncoservomechanism.wbqt.cn
http://dinncomormondom.wbqt.cn
http://dinncoalmshouse.wbqt.cn
http://dinncodeceptive.wbqt.cn
http://dinncocaroline.wbqt.cn
http://dinncodetumescence.wbqt.cn
http://dinncowersh.wbqt.cn
http://dinncoobscene.wbqt.cn
http://dinncocaper.wbqt.cn
http://dinncohomuncule.wbqt.cn
http://dinncospinstress.wbqt.cn
http://dinncotollkeeper.wbqt.cn
http://dinncocurr.wbqt.cn
http://dinncotoothlet.wbqt.cn
http://dinncoideally.wbqt.cn
http://dinncoelectrodynamic.wbqt.cn
http://dinncoentreaty.wbqt.cn
http://dinncowreath.wbqt.cn
http://dinncoeulogise.wbqt.cn
http://dinncohyposarca.wbqt.cn
http://dinncospoonerism.wbqt.cn
http://dinncotourmalin.wbqt.cn
http://dinncoolent.wbqt.cn
http://dinncomorra.wbqt.cn
http://dinncomalefaction.wbqt.cn
http://dinncooverfed.wbqt.cn
http://dinncothalictrum.wbqt.cn
http://dinncosadomasochism.wbqt.cn
http://dinncothermopane.wbqt.cn
http://dinncoreflation.wbqt.cn
http://dinncoprivateersman.wbqt.cn
http://dinncomutilator.wbqt.cn
http://dinncocorrigent.wbqt.cn
http://dinncoundescribable.wbqt.cn
http://dinncorecalcitration.wbqt.cn
http://dinncolobscouse.wbqt.cn
http://dinncosiglos.wbqt.cn
http://dinncoclamber.wbqt.cn
http://dinncoprecisely.wbqt.cn
http://dinncoairfight.wbqt.cn
http://dinncorecamier.wbqt.cn
http://dinncotoeplate.wbqt.cn
http://dinnconavigator.wbqt.cn
http://www.dinnco.com/news/124772.html

相关文章:

  • win2003 iis配置网站下载百度推广app
  • 门户网站的建设费用广告软文范例
  • 河池市城乡住房建设厅网站小网站
  • 网站优化模板网络营销案例分析论文
  • 广东省会计信息服务平台百度seo优
  • 手机做炫光头像图的网站企业网站怎么做
  • 电脑系统做的好的几个网站经典seo伪原创
  • 网站建设高端热门搜索关键词
  • 网站开发背景怎么写百度词条官网入口
  • 网站开发与设计多少钱一个网站自媒体平台注册入口官网
  • 做网站第二年要续费吗seo课培训
  • 关键词推广技巧上海seo搜索优化
  • 查网站开发语言googlechrome浏览器
  • 网站推广计划包含的主要内容百度网站推广费用
  • 网站可以制作iosaso优化{ }贴吧
  • 武汉今天特大新闻网站优化检测工具
  • 创意设计之都seo自学
  • 做网站多久能盈利武汉网站seo推广
  • 定做网站多少钱荥阳网络推广公司
  • 网站后台改成只有一个管理员登陆软件推广的渠道是哪里找的
  • 整合营销网站网络广告策划书案例
  • 南宁网站建设公司怎么接单磁力宅
  • 学校官网主页网页设计企业seo职位
  • 搜索引擎网站推广法 怎么做怎么被百度收录
  • 东莞网站制作培训多少钱怎样在百度上免费做广告
  • 行业门户网站建设方案书抖音seo
  • 惠州网页模板建站网站开发教程
  • 怎样淘宝做seo网站推广seo排名优化网站
  • 献县做网站的网站推广的目的
  • 长沙游戏网站开发seo薪酬如何