文章

82

粉丝

343

获赞

27

访问

660.8k

头像
简单模拟
P1501 西北工业大学2015机试题
发布于2021年1月31日 16:58
阅读数 7.7k

#include <iostream>
#include <stack>
#include <string>
using namespace std;

stack <char> st;
string s;
int main(){
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='('||s[i]=='[') {
            st.push(s[i]);
        }
        if(s[i]==')'){
            if(!st.empty()){
                if(st.top()!='('){
                    cout<<"NO";
                    return 0;
                }
   &nbs...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发