文章

25

粉丝

0

获赞

109

访问

3.7k

头像
括号匹配2 题解:

#include<iostream>
#include<string>
#include<stack>
using namespace std;
int main(){
    string str1;
    while(cin>>str1){
        bool flag=1;
        stack<char>st1;
        for(int i=0;i<str1.size();i++){
            if(str1[i]=='<'||str1[i]=='('||str1[i]=='{'||str1[i]=='['){
                st1.push(str1[i]);
            }
            else if(str1[i]=='>'){
                if(st1.empty()||st1.top()!='<'){
                    flag=0;
                    break;
                }
   ...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发