diff --git a/Stack/appliance/braket-match.cpp b/Stack/appliance/braket-match.cpp new file mode 100644 index 0000000..716b275 --- /dev/null +++ b/Stack/appliance/braket-match.cpp @@ -0,0 +1,35 @@ +#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; +} diff --git a/Stack/appliance/braket-match.exe b/Stack/appliance/braket-match.exe new file mode 100644 index 0000000..4001084 Binary files /dev/null and b/Stack/appliance/braket-match.exe differ