C++中栈和队列的简单使用

来源:互联网 发布:程序员专用计算器 编辑:程序博客网 时间:2024/04/28 16:37

    1.栈的简单使用

stack<int> st;//初始化//push three elements into the stackst.push(1);//:push函数st.push(2);st.push(3);//print the size of the stackcout<<"the length is"<<st.size()<<endl;//:size()//pop and print two elements from the stackscout<<st.top()<<' ';// top()st.pop();//pop()cout<<st.top()<<' '<<endl;st.pop();//modify top elementst.top()=77;while(!st.empty()){//empty()cout<<st.top()<<"--";st.pop();}


原创粉丝点击