第二课 栈_队列_堆
内容概览及预备知识: 预备知识:栈与队列: STL基本的栈操作(stack): 1 #include <iostream> 2 using namespace std; 3 4 #include <stack> 5 int main(){ 6 stack <int> stk; 7 if(stk.empty()){ //判断是否为空 isempty() 8 cout <<"The Stack is empty!!!"<<endl; 9 } 10 stk.push(5); //压栈 11 stk.push(6); 12 stk.push(10); 13 14 cout <<"The Stack' top is " <<stk.top()<<endl; 15 stk.pop(); //弹出栈顶 16 stk.pop(); 17 cout <<"The Stack' top is "<<stk.top()<<endl; 18 cout <<"The Stack' size is "<<stk.size()<<endl; //栈中的size 19 20 return 0; 21 } View Code STL基本的队列操作(queue): 1 #include <iostream> 2 using namespace std; 3 4 #include <queue> 5 int main(