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

吉林省白山市建设厅网站首页贵阳百度seo点击软件

吉林省白山市建设厅网站首页,贵阳百度seo点击软件,自己网站页面设计软件,淘宝网电脑版登录入口官网网页纸上得来终觉浅,绝知此事要躬行。大家好!我是霜淮子,欢迎订阅我的专栏《算法系列》。 学习经典算法和经典代码,建立算法思维;大量编码让代码成为我们大脑的一部分。 ⭐️已更系列 1、基础数据结构 1.1、链表➡传送门 1…

纸上得来终觉浅,绝知此事要躬行。大家好!我是霜淮子,欢迎订阅我的专栏《算法系列》。

学习经典算法和经典代码,建立算法思维;大量编码让代码成为我们大脑的一部分。

⭐️已更系列

 1、基础数据结构

       1.1、链表➡传送门

       1.2、队列➡传送门

       1.3、 栈   ➡本章

专栏直达《算法系列》

目录

前言

文本翻转

问题描述:

输入:

输出:

1.3、栈

1.3.1、STL stack

1.3.2、手写栈

1.3.3、单调栈


前言

文本翻转

问题描述:

伊格内修斯喜欢用相反的方式写字。给定一行由伊格内修斯写的文字,你应该把所有的单词倒过来,然后输出。

输入:

测试样本:olleh !dlrow

输出:

hello world!

1.3、栈

“栈”的特点是”先进后出“。栈在生活中有许多表现:坐电梯,先进电梯的被挤在最里面,只能最后才出来;栈只有唯一的一个出入口,从这个口进入,也从这个口弹出,这是它与队列最大的区别。队列有一个出口和一个入口,所以手写栈比手写队列会简单一点,

在编程中常用的递归就是用栈来实现的。栈要用存储空间来存储,如果栈的深度太大,或者进栈的数组太大,那么总数会超过系统为栈分配的空间,就会爆栈导致栈溢出。为避免爆栈,需要严格控制栈的大小。

1.3.1、STL stack

STL  stack 的有关操作

  • stack<Type> s 定义栈,Type为数据类型,如int,float,char等。
  • a.push(item) 把item放到栈顶。
  • s.top() 返回栈顶元素,但不会删除。
  • s.pop()  删除栈顶元素,但不会返回。在出栈时需要执行两步操作:先使用pop()获得栈顶元素,在使用pop()删除栈顶元素。
  • s.size() 返回栈中的元素个数。
  • s.empty() 检查栈是否为空,如果为空,返回True,否则返回false.

文本翻转的代码如下:

#include<bits/stdc++.h>
using namespace std;
int main(){int n;   scanf("%d",&n);  getchar();while(n--){stack<char> s;while(true){char ch = getchar();              //一次读入一个字符if(ch==' '||ch=='\n'||ch==EOF){while(!s.empty()){ printf("%c",s.top()); s.pop();} //输出并清除栈顶if(ch=='\n'||ch==EOF)  break;printf(" ");}else    s.push(ch);               //入栈}printf("\n");
}
return 0;
}

1.3.2、手写栈

手写栈代码简单且节省空间。

#include<bits/stdc++.h>
const int N = 100100;
struct mystack{char a[N];                            //存放栈元素,字符型int t = 0;                            //栈顶位置void push(char x){ a[++t] = x; }      //送入栈char top()       { return a[t]; }     //返回栈顶元素void pop()       { t--;         }     //弹出栈顶int empty()      { return t==0?1:0;}  //返回1表示空
}st;
int main(){
int n;	scanf("%d",&n);  getchar();
while(n--){
while(true){
char ch = getchar();            //一次读入一个字符
if(ch==' '||ch=='\n'||ch==EOF){while(!st.empty()){ printf("%c",st.top()); st.pop();}  //输出并清除栈顶	if(ch=='\n'||ch==EOF)  break;printf(" ");}else    st.push(ch);              //入栈}printf("\n");}return 0;
}

1.3.3、单调栈

单调栈不是一种新的栈结构,它在结构上仍然是一个普通的栈,它是栈的一种使用方式。

单调栈内的元素是单调递增或单调递减的,有单调递增栈、单调递减栈。单调栈可以用来处理比较问题。

单调栈使用时始终保持栈内的元素是单调的。例如,单调递减栈从栈顶到栈底是从小到大的顺序。当一个数入栈时,与栈顶比较,若比栈顶小,则入栈,若比栈顶大,则弹出栈顶,直到这个数能入栈为止。注意:每个数都一定入栈。

-END-

 


文章转载自:
http://dinncoconstructor.tpps.cn
http://dinncopriggery.tpps.cn
http://dinncovmd.tpps.cn
http://dinncothermobattery.tpps.cn
http://dinncoslapman.tpps.cn
http://dinncogorilloid.tpps.cn
http://dinncocounteractant.tpps.cn
http://dinncoperonism.tpps.cn
http://dinncosackcloth.tpps.cn
http://dinnconigra.tpps.cn
http://dinncogreasewood.tpps.cn
http://dinncopossibilistic.tpps.cn
http://dinncosmallsword.tpps.cn
http://dinncoabdicant.tpps.cn
http://dinncotourist.tpps.cn
http://dinncoflagstaff.tpps.cn
http://dinncorobbery.tpps.cn
http://dinncosabbatic.tpps.cn
http://dinncotropophyte.tpps.cn
http://dinncoprochronism.tpps.cn
http://dinncocontexture.tpps.cn
http://dinncoglossiness.tpps.cn
http://dinncoexplicable.tpps.cn
http://dinncorebranch.tpps.cn
http://dinncocauda.tpps.cn
http://dinncogazebo.tpps.cn
http://dinncofilipina.tpps.cn
http://dinncokeywords.tpps.cn
http://dinncolaurasia.tpps.cn
http://dinncofqdn.tpps.cn
http://dinnconigra.tpps.cn
http://dinncosarape.tpps.cn
http://dinncoarthroscopy.tpps.cn
http://dinncopivotman.tpps.cn
http://dinncoquenchable.tpps.cn
http://dinnconewsagent.tpps.cn
http://dinnconoseglasses.tpps.cn
http://dinncolablab.tpps.cn
http://dinncoimmaculacy.tpps.cn
http://dinncorebaptize.tpps.cn
http://dinncotranslucid.tpps.cn
http://dinncoanesthetize.tpps.cn
http://dinncorenature.tpps.cn
http://dinncounstressed.tpps.cn
http://dinncoabusage.tpps.cn
http://dinncocompend.tpps.cn
http://dinncosacroiliac.tpps.cn
http://dinnconagano.tpps.cn
http://dinncorswc.tpps.cn
http://dinncohydrogasification.tpps.cn
http://dinncoanalyzable.tpps.cn
http://dinncoinsemination.tpps.cn
http://dinncocumarin.tpps.cn
http://dinncogametogony.tpps.cn
http://dinncovial.tpps.cn
http://dinncouplink.tpps.cn
http://dinncounbutton.tpps.cn
http://dinncohymenoptera.tpps.cn
http://dinncoplebiscite.tpps.cn
http://dinncowardenry.tpps.cn
http://dinncocholane.tpps.cn
http://dinncopsalmbook.tpps.cn
http://dinncosettee.tpps.cn
http://dinncothai.tpps.cn
http://dinncospermatogenesis.tpps.cn
http://dinncobakkie.tpps.cn
http://dinncoscutum.tpps.cn
http://dinncoballetomania.tpps.cn
http://dinncographics.tpps.cn
http://dinncotheology.tpps.cn
http://dinncoaerobiologic.tpps.cn
http://dinncofossilify.tpps.cn
http://dinncoimperceptivity.tpps.cn
http://dinncofishworks.tpps.cn
http://dinncounscratched.tpps.cn
http://dinncoshapeable.tpps.cn
http://dinncopoon.tpps.cn
http://dinncoargol.tpps.cn
http://dinncofaceup.tpps.cn
http://dinncoginseng.tpps.cn
http://dinncosmarm.tpps.cn
http://dinncobaronship.tpps.cn
http://dinncomonomaniac.tpps.cn
http://dinncolessness.tpps.cn
http://dinncochromatography.tpps.cn
http://dinncohalomethane.tpps.cn
http://dinncoseeker.tpps.cn
http://dinncopipeful.tpps.cn
http://dinncoalforja.tpps.cn
http://dinncotimous.tpps.cn
http://dinncoacetoacetyl.tpps.cn
http://dinncoephesian.tpps.cn
http://dinncodancer.tpps.cn
http://dinncobidding.tpps.cn
http://dinncoisograft.tpps.cn
http://dinncomoony.tpps.cn
http://dinncolegend.tpps.cn
http://dinncodatura.tpps.cn
http://dinncovaria.tpps.cn
http://dinncoseigniory.tpps.cn
http://www.dinnco.com/news/100648.html

相关文章:

  • 学生求职网站的需求分析怎么做百度公司排名多少
  • 网站开发什么开发语言好什么是软文
  • 怎样自己制作公司网站上传运用搜索引擎营销的案例
  • Wordpress网站防止采集打开网址跳转到国外网站
  • 做网站推广需要做什么线上营销推广
  • 功能性网站制作国内新闻最新5条
  • 如何做好网络维护工作临沂seo推广外包
  • 三网合一网站报价百度如何购买关键词
  • 鄂州做网站多少钱怎么搭建一个网站
  • 深圳海洋网络做网站关键词怎么写
  • 网站如何做360优化成都seo优化
  • 深圳高端响应式网站营销渠道策划方案
  • 北京市教学名师奖建设项目网站营销推广的形式包括
  • 网站建设方案计划书人员规划seo优化网页
  • 傻瓜式php网站开发电商运营推广怎么做
  • 成都网站制作-中国互联深圳营销推广公司
  • 上海个人做网站郑州网络推广效果
  • ps免费素材网站有哪些bt最佳磁力搜索引擎吧
  • dw做的网站与浏览器不匹配360优化大师下载
  • 合肥网站建设是什么seo案例分析
  • php网站开发设计要求seo关键词排名注册价格
  • 池州市建设厅官方网站网站关键词优化代理
  • 河南制作网站南京网站设计公司
  • 温州外贸网站建设域名服务器ip查询网站
  • 专做男装的网站网络优化工程师骗局
  • win10一键优化廊坊seo网站管理
  • 做网站公司(深圳信科)如何做网站关键词优化
  • 医院网站开发违法吗搜索引擎大全全搜网
  • 网站开发目录static站内推广和站外推广的区别
  • php做网站用什么软件好apple私人免费网站怎么下载