hdu1702 list or stack+queue
List or Queue Stack
2023-09-11 14:16:05 时间
http://acm.hdu.edu.cn/showproblem.php?pid=1702
#include iostream #include cstdio #include cstring #include list using namespace std; int main() // freopen("1.txt","r",stdin); int n; scanf("%d", while(n--) int m,i,x; list int li.clear(); char s[10],ss[10]; scanf("%d %s", m,s); if(strcmp(s,"FIFO")==0) for(i=0; i i++) scanf("%s",ss); if(strcmp(ss,"IN")==0) cin x; li.push_back(x); else if(li.empty()) cout "None" endl; else cout li.front() endl; li.pop_front(); else for(i=0; i i++) scanf("%s",ss); if(strcmp(ss,"IN")==0) cin x; li.push_back(x); else if(li.empty()) cout "None" endl; else cout li.back() endl; li.pop_back(); return 0;
#include iostream #include cstdio #include cstring #include stack #include queue using namespace std; int main() // freopen("1.txt","r",stdin); int n,x,m; char s[10],ss[10]; stack int queue int scanf("%d", while(n--) while(!st.empty()) st.pop(); while(!q.empty()) q.pop(); scanf("%d %s", m,s); if(strcmp(s,"FILO")==0) for(int i=0; i i++) scanf("%s",ss); if(strcmp(ss,"IN")==0) cin x; st.push(x); else if(st.empty()) cout "None" endl; else cout st.top() endl;; st.pop(); else for(int i=0; i i++) scanf("%s",ss); if(strcmp(ss,"IN")==0) cin x; q.push(x); else if(q.empty()) cout "None" endl; else cout q.front() endl; q.pop(); return 0;
Java编程之LinkedList+Vector+Stack+Queue Vector类 1.java.util包 2.是ArrayList集合的早期版本 (StringBuffer早期 StringBuilder后来) Vector底层也是利用(动态)数组的形式存储 Vector是线程同步的(synchronized) 安全性高 效率低 3.扩容方式与ArrayList不同 默认是扩容2倍 可以通过构造方法创建对象时修改这一机制 4.构造方法 5.常用方法 Stack类 栈 1.java.util包 2.构造方法只有一个无参数 3.除了继承自Vacton类
Vector和Stack源码分析/List集合的总结 这篇文章算是在这list接口下的集合的最后一篇了,前面ArrayList、LinkedList都已经讲解完了,剩下就Vector和Vector的子类Stack啦。继续努力。一步一个脚印,
给出 -21- 10- 4- 5, tail connects to node index 1,返回 true。 这里解释下,题目的意思,在英文原题中,tail connects to node index 1 表示的是节点 5 还要链接回索引号 为 1 的节点。
相关文章
- springmvc: 普通list数据输出json
- java mongodb 基础系列---查询,排序,limit,$in,$or,输出为list,创建索引,$ne 非操作
- java mongodb 基础系列---查询,排序,limit,$in,$or,输出为list,创建索引,$ne 非操作
- [Spring学习笔记 2 ]装配各种类型的属性 map,list,array,null,properties
- [Algorithm] 234. Palindrome Linked List / Reverse linked list
- Java的List转Scala的数组
- why is list delete and edit icon rendered
- SAP UI5 Dropdown list binding debugging
- SAP CRM One Order status drop down list generation
- Atitit 遍历文件夹目录解决方案与规范 attilax总结 1. 规范2 1.1. 注意的不要同时改变文件夹内容,增删文件。这样获取到的目录list不会变化2 1.2. 主义中文名称文件读写
- Atitit r2017 r5 doc list on home ntpc.docx 驱动器 D 中的卷是 p2soft 卷的序列号是 9AD0-D3C8 D:atir2017 v4 r
- 成功解决ValueError: ‘usecols‘ must either be list-like of all strings, all unicode, all integers or a ca
- 已解决TypeError:List indices must be integers or slices , not str
- [to do list][PCB][questions]and[plan]
- LVGL 8.2 menu from a drop-down list
- LVGL 8.2 Simple Drop down list
- ledisDB底层实现——本质上就是用leveldb这样的底层存储,和ssdb一样,meta里存的是hash、list等的元数据
- 【Java】一篇文章带你了解Collection接口、List集合、Set集合、Map集合