编译错误!回复必关!!!!!!!!!!!!
查看原帖
编译错误!回复必关!!!!!!!!!!!!
1637519
tuomiao楼主2025/1/23 11:39
#include <iostream> 
#include <stack> 
using namespace std; 
 
int main() { 
    int T; 
    cin >> T; 
    while (T--) { 
        int n; 
        cin >> n; 
        stack<long long> st; 
        for (int i = 0; i < n; i++) { 
            string op; 
            cin >> op; 
            if (op == "push") { 
                long long num; 
                cin >> num; 
                st.push_back(num);  
            } else if (op == "pop") { 
                if (st.empty())  { 
                    cout << "Empty" << endl; 
                } else { 
                    st.pop_back();  
                } 
            } else if (op == "query") { 
                if (st.empty())  { 
                    cout << "Anguei!" << endl; 
                } else { 
                    cout << st.back()  << endl; 
                } 
            } else if (op == "size") { 
                cout << st.size()  << endl; 
            } 
        } 
    } 
    return 0; 
} 
 
 
2025/1/23 11:39
加载中...