舅舅我!
查看原帖
舅舅我!
1373155
rhy1314楼主2024/12/7 22:01

最后一个输出有问题

要加个换行

#define ll long long
#define ci cin>>
#include <bits/stdc++.h>
using namespace std;
stack<int> s;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int i;
    ci i;
    string a;
    for(;i>=1;i--){
            int j;ci j;
            for(;j>=1;j--){
                cin>>a;
                if(a[0]=='p'&&a[1]=='u'){
                    int x;ci x;
                    s.push(x);
                }
                else if(a[0]=='p'&&a[1]=='o'){
                    if(s.empty()){
                        cout<<"empty"<<endl;
                    }
                    else s.pop();
                }
                else if(a[0]=='q'){
                    if(s.empty()){
                        cout<<"Auguei!"<<endl;
                    }
                    else{
                        cout<< s.top()<<endl;
                    }
                }
                else if(a[0]=='s'){
                    cout<<s.size()<<endl;
                }
            }
    }
    return 0;
}
2024/12/7 22:01
加载中...