QAQ求条(玄关)

B3614 【模板】栈

zsq9 @ 2024-10-20 17:08:44

实在找不出问题了

#include<bits/stdc++.h>
using namespace std;

unsigned long long a,c,e;   
stack < long long int> b;
string d;
int main(){
    cin>>a;
    while(a--){
        scanf("%lld",&c);
        while(!b.empty())b.pop();
        while(c--){
            cin>>d;
            if(d=="push"){
                scanf("%llu",&e);
                b.push(e);
            }else if(d=="query"){
                if(b.empty()==1){
                    printf("Anguei!\n");    
                }else{
                    printf("%lld\n",b.top());
                }
            }else if(d=="pop"){
                if(b.empty()==1){
                    printf("Empty\n");
                }else{
                    b.pop();
                }
            }else{
                printf("%lld\n",b.size());
            }
        }
    }

return 0;
}

by luohoujunyang @ 2024-10-20 17:15:25

@zsq9

stack < long long int> b;改为stack < unsigned long long> b;

printf("%lld\n",b.top());改为printf("%llu\n",b.top());


by zsq9 @ 2024-10-20 17:17:48

@luohoujunyang 谢谢,这题把我该红温了。


|