题解
2025-06-14 11:05:03
发布于:浙江
0阅读
0回复
0点赞
#include<iostream>
#include<string>
using namespace std;
char a[260];
int top;
void push(char x){
    a[++top]=x;
}
void pop(){
    --top;
}
bool empty(){
    return top==0;
}
int main(){
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='('){
            push(s[i]);
        }else if(s[i]==')'){
            if(empty()){
                cout<<"NO";
                return 0;
            }else{
                pop();
            }
        }else if(s[i]=='@'){
            break;
        }
    }
    if(empty()){
        cout<<"YES";
    }else{
        cout<<"NO";
    }
    return 0;
}
这里空空如也







有帮助,赞一个