求助,60C++
查看原帖
求助,60C++
555590
伏地魔老杨楼主2022/7/1 22:19
#include <iostream>
#include <stack>
#include <string>
using namespace std;

stack<char> st1, st2; 

int main()
{
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == '(' && !st2.empty()) st2.pop();
        else st1.push(s[i]);
        if (s[i] == ')' && !st1.empty()) st1.pop();
        else st2.push(s[i]);
        if (s[i] == '@') break;
    }
    if (st1.empty() && st2.empty()) cout << "YES";
    else cout << "NO";
    return 0;
}
2022/7/1 22:19
加载中...