大佬 救急
查看原帖
大佬 救急
330838
yang123yang楼主2022/2/22 20:23

这是我的代码 感觉是没问题的 但是第二个点就过不去 帮帮dd

#include<iostream>
#include<stack>
using namespace std;
stack<char>a;
int main(){
    int k;
    while(cin>>k){
        if(k==a.empty()&&k==')') {
            cout<<"NO"<<endl;
            return 0;
        }
        if(k=='(') a.push(k);
        if(k==')'){
            a.pop();
        }
  }
    if(a.empty()) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;

}

2022/2/22 20:23
加载中...