就是这么简单
2023-08-16 09:49:47
发布于:广东
0阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
char n;
struct Stack{
int top,a[100000];
void inti(){ top=0; }
void push(int x){ a[++top]=x; }
void pop(){ if(top) top--; }
int empty(){
if(top>0) return 0;
else return 1;
}
int quary(){ return a[top]; }
}z;
int main(){
z.inti();
while(cin>>n){
if(z.empty()){
if(n==')'){
cout<<"NO";
return 0;
}
}
if(n=='(') z.push(n);
if(n==')') z.pop();
}
if(z.empty()) cout<<"YES";
else cout<<"NO";
return 0;
}
这里空空如也
有帮助,赞一个