单调栈
来源:互联网 发布:一淘和淘宝联盟一起用 编辑:程序博客网 时间:2024/04/25 15:25
给定一组数,做成单调递增栈(栈底到栈顶递增),一组数的选择会影响到这个程序
#include<stack>#include<iostream>#include<cstdio>using namespace std;int main(){ int a[10]={1,5,9,2,4,2,6,10},i; stack<int>s; while(!s.empty()) s.pop(); s.push(a[0]); for(i=1;i<=7;i++) { while(a[i]<s.top()&&!s.empty()) s.pop(); s.push(a[i]); } while(!s.empty()) { printf("%d ",s.top()); s.pop(); } return 0;}
0 0
- 单调栈 单调队列
- 单调栈
- 单调栈
- 单调栈
- 单调栈
- 单调栈
- 单调栈
- 单调栈
- 单调栈
- 单调栈
- 单调栈
- 单调栈
- 单调栈
- 单调栈
- 单调栈
- 单调栈
- 单调栈
- 单调栈
- 将代码上传至github
- 二叉树递归非递归遍历(递归前中后,非递归前中后,层次遍历,凹入打印法等)
- Problem A(逆元) 2016"百度之星" - 资格赛(Astar Round1)
- windows下的caffe配置过程
- 在ListView中实现动画效果
- 单调栈
- 2016年 团体程序设计天梯赛 - 模拟赛
- CSDN博客中使用目录
- transient使用
- shell 第一个简单的脚本和变量
- java 常用弹出框
- 将本地项目上传至CSDN代码创库
- 第一章作业题
- esxi在终端开启命令行模式