#include #include #include #include using namespace std; void isMatch(const string& s){ stack t; //bool error = false; for(int i = 0; i < s.length(); i++){ if(s[i] == '('){ t.push(i); } if(s[i] == ')'){ try{ if(t.empty()) throw std::runtime_error("Error: Braket \" ) \" No Match"); t.pop(); } catch(const runtime_error& e){ cout << e.what() << endl; //error = true; return; } } } if(t.empty()) cout << "Match" << endl; else cout << "Error: Braket \" ( \" No Match" << endl; } int main(){ string s; cin >> s; isMatch(s); return 0; }