进食后人

B3614 【模板】栈

yuechenxi130407 @ 2024-10-06 10:42:51

多测不清空,情人亲人两行泪。
详见代码:

#include <bits/stdc++.h>
using namespace std;
vector <unsigned long long> v;
int main() {
    int t;
    cin>>t;
    while (t--){
        int n;
        cin>>n;
        string s;
        for (int i=0;i<n;++i){
            cin>>s;
            if (s=="push"){
                unsigned long long x;
                cin>>x;
                v.push_back(x);
            }
            else{
                if (s=="pop"){
                    if (v.size())v.pop_back();
                    else cout<<"Empty"<<endl;
                }
                else if(s=="size")
                    cout<<v.size()<<endl;
                else{
                    if (!v.size())
                        cout<<"Anguei!"<<endl;
                    else
                        cout<<v[v.size()-1]<<endl;
                }
            }
        }
    }
    return 0;
}

66pts


by lzy120406 @ 2024-10-06 10:47:36

分数挺吉利


by yuechenxi130407 @ 2024-10-06 10:56:14

@lzy120406
你真会观察


by chen0717 @ 2024-10-14 11:16:39

cc


|