1 solutions

  • 0
    @ 2025-3-3 16:32:54

    C++ :

    #include<bits/stdc++.h>
    
    using namespace std;
    queue <string> q;
    int main()
    {
    	
        string s,name;
        while(cin>>s)
        {
            if(s == "PUSH")
            {
                cin>>name; 
                q.push(name);
            }
            if(s == "POP")
            {
                if(q.empty())
                {
                    cout<<"EMPTY"<<endl;
                }
                else
                {
                    cout<<q.front()<<endl;
                    q.pop();
                }
            }
            if(s == "END")
            {
                break;
            }
        }
        return 0;
    }
    
    
    • 1

    Information

    ID
    10485
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By