摘要: 面试题:栈的压入、弹出序列题目:输入两个整数序列,第一个序列表示栈的压入顺序,请判断第二个序列是否为该栈的弹出顺序。假设压入栈的所有数字均不相等。例如序列1、2、3、4、5是某栈的压栈序列,序列4、5、3、2、1是该压栈序列的弹出序列,但4、3、5、1、2就不可能是该压栈序列的弹出序列。#inclu... 阅读全文
posted @ 2014-03-27 21:34 zhoudan 阅读(260) 评论(0) 推荐(0) 编辑
摘要: 样例 计算4+2*3-10/5#include#include#include#include#includeusing namespace std;//比较运算符的优先级int MatchOper(char str1,char str2){ if(str1=='+'||str1=='-') { ... 阅读全文
posted @ 2014-03-27 20:27 zhoudan 阅读(1076) 评论(0) 推荐(0) 编辑
摘要: queue(class T,class Container=deque) 创建元素类型为T的空队列,默认容器是dequestack(class T,class Container=deque) 创建元素类型为T的空堆栈,默认容器是deque队列和堆栈共有函数bool empty() 如果队列(堆栈)... 阅读全文
posted @ 2014-03-27 15:25 zhoudan 阅读(82) 评论(0) 推荐(0) 编辑
摘要: #include#include#includeusing namespace std;class Student{ string m_strNO;string m_strName;string m_strUniversity;int m_nTotal; //总分public:Student(str... 阅读全文
posted @ 2014-03-27 14:01 zhoudan 阅读(303) 评论(0) 推荐(0) 编辑
摘要: (1) 重载输出运算符 <<ostream& operator<<(ostream& os,Student& s) //其中Student是一个类类型的数据结构{os<<s.GetNO()<<"\t"<<s.GetName()<<"\t"<<s.GetUniversity()<<"\t"<<s.Ge... 阅读全文
posted @ 2014-03-27 10:40 zhoudan 阅读(101) 评论(0) 推荐(0) 编辑
摘要: 相对于vector的连续线性空间,list是一个双向链表,它有一个重要性质:插入操作和删除操作都不会造成原有的list迭代器失效,每次插入或删除一个元素就配置或释放一个元素空间。也就是说,对于任何位置的元素插入或删除,list永远是常数时间。 常用函数int size() const 返回容器元素... 阅读全文
posted @ 2014-03-27 10:26 zhoudan 阅读(102) 评论(0) 推荐(0) 编辑