问题标题: {}{}不对

0
0
邱奕然
邱奕然
初级守护
初级守护

#include<bits/stdc++.h>
using namespace std;
int n,t[305];
string s;
string f(string s)
{
    stack<char>st;
    for(int i=0;i<s.size();i++)
    {
        if(t[s[i]]>0)
            st.push(s[i]);
        }
        else
        {
            if(st.empty())
            {
                return "Wrong";
            }
            else
            {
                if(t[st.top()]+t[s[i]]==0)
                {
                    st.pop();
                }
                else
                {
                    return "Wrong";
                }
            }
        }
    }
    if(st.empty())
    {
        return "OK";
    }
    else
    {
        return "Wrong";
    }
}
int main()
{
    t['(']=2;
    t['[']=3;
    t[')']=-2;
    t[']']=-3;
    cin>>n;
    while(n--)
    {
        cin>>s;
        cout<<f(s)<<endl;
    }
    return 0;
}


0
0
0
0
0
马泓毅
马泓毅
高级守护
高级守护

???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

0
0
我要回答