queue stack usage

queue

Queue, FIFO, queue, the tail queue head

    queue<int> que;
    for(int i=0;i<6;i++)
        que.push(i);
    cout<<que.front()<<endl<<que.back();
    que.pop();
    que.empty();
    que.size();

Team head pop out of team

push the tail queue

front and back just to take elements, additions and deletions do not

 

 

stack

Stack, last-out

    stack<int> st;
    for(int i=0;i<6;i++)
        st.push(i);
    cout<<st.top()<<endl;
    st.pop();
    st.empty();
    st.size();

pop stack pop

push the stack onto the stack

deletions not only take the top element

Guess you like

Origin www.cnblogs.com/lxzbky/p/12545426.html