#include <iostream> #include <string> #include <stack> #include <vector> using namespace std; int main(){ string str; string left = "([{"; string right = ")]}"; stack<char> st; int len = str.length(); while (cin >> str){ for (int i = 0;i<str.length();i++){ if (str[i] == '(' || str[i] == '[' || str[i] == '{'){ st.push(str[i]); } else{ if (st.empty()||st.top()!=left[right.find(str[i])]) cout << "false" << endl; else st.pop(); } } if (st.empty()) cout << "true"; else cout << "false"; } return 0; } ///注意:{[]}为 输出为错误 vaild parenthless问题