洛谷-1739

#include<iostream>
#include<stack>
using namespace std;
int main()
{
    char a[300];
    int i=0;
    stack<char>m;
    cin>>a;
    while(a[i]!='@')
    {
        if(a[i]=='(')
            m.push(a[i]);
        else if(a[i]==')'&&m.empty()==0)
                m.pop();
        else if(a[i]==')'&&m.empty()!=0)
                {
                    cout<<"NO";
                    return 0;
                }
        i++;                                   ///加上不然死循环了;
    }
    if(m.empty()==0)
        cout<<"NO";
    else
        cout<<"YES";
    return 0;
}

猜你喜欢

转载自blog.csdn.net/wentong_xu/article/details/79838059