Usage stack and queue function

//s.empty (); // if the stack is empty returns true, otherwise returns to false;
//s.size (); // returns the number of elements in the stack
//s.top (); // Returns top element, but does not delete the element
//s.pop (); // pop stack elements, but does not return a value
//s.push (); // the element onto stack
 // queue
// q.empty (); // if the queue is empty returns true, otherwise it returns false     
//q.size (); // returns the number of elements in the queue
//q.front (); // returns the first element but team does not remove the element
//q.pop (); // pop elements, but not the first team to return its value
//q.push (); // element is pressed into the queue
//q.back (); // return team Last but not the value of the element to remove the element

#include<stdio.h>
#include<stack>
#include<queue>
#include<iostream>
using namespace std;
int main()
{
    stack<int> S;
    queue<int>Q;
    for(int i=0;i<10;i++)
    S.push(i);
    while(!S.empty())
    {
        Q.push(S.top());
        S.pop();    
    }
    while(!Q.empty())
    {
        cout<<Q.front()<<" ";
        Q.pop();
    }
}
 

Released three original articles · won praise 0 · Views 469

Guess you like

Origin blog.csdn.net/qq_41404210/article/details/104685369