题目1522:包含min函数的栈
2013-09-24 22:33
363 查看
http://ac.jobdu.com/problem.php?pid=1522
我想到了用multiset的方法
View Code
我想到了用multiset的方法
#include<stdio.h> int sta[1009999]; int min(int a,int b){ if(a>b)return b; else return a; } int main() { int n; sta[0]=999999999; while(scanf("%d",&n)!=EOF){ int i,add=0; char s[9]; int temp; for(i=1;i<=n;i++){ scanf("%s",s); if(s[0]=='s'){ add++; scanf("%d",&temp); sta[add]=min(sta[add-1],temp); printf("%d\n",sta[add]); }else{ add--; if(sta[add]==999999999) printf("NULL\n"); else printf("%d\n",sta[add]); } } } return 0; }
View Code
相关文章推荐
- HDU 4122 Alice's mooncake shop (单调队列/线段树)
- servlet核心API的UML图
- 什么叫应用程序域?(zhuan)
- 提高代码质量的Eclipse插件之JDepend
- 《算法竞赛-训练指南》第五章-5.1_UVa 11624
- C语言左移右移
- remove函数1
- Java栈与堆 (转)
- linux make
- Windows下安装wundle
- C++的单例模式
- 对话框中获取doc,view指针:
- 有人说:牛人,应该拥有自己的博客
- Windows下安装wundle
- Android项目导入出现问题解决方案
- 成为Java高手的25个学习要点
- error C2065: “IDD_DIALOG1”: 未声明的标识符 .
- 腾讯后台开发面试题及答案
- Java网络编程:UDP通信
- 李一男离开华为时给属下的忠告