【队列】数组模拟(AcWing829.模拟队列)
AcWing829.模拟队列

#include <iostream>
using namespace std;
const int N = 1e5+10;
int q[N], hh, tt;
int main()
{
    int n, k;
    cin >> n;
    string c;
    while( n -- )
    {
        cin >> c;
        if(c == "push") cin >> k, q[tt ++ ] = k;
        else if(c == "pop") hh ++ ;
        else if(c == "empty") cout << (hh == tt ? "YES":"NO") << endl;
        else cout << q[hh] << endl;
    }
    return 0;
}

 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号