here is my code it is working fine now but not giving the desire output
ex for eq {a+(b-c)*d} the output should be
"bracket matched popping )
bracket matched popping }"
but output is
"bracket dose not matched"
#include <bits/stdc++.h>
using namespace std;
main() {
string exp;
cin >> exp;
// cin.getline(exp);
stack <char> s;
for(int i = 0; exp[i] != '\0'; i++) {
if(exp[i] == '{' || exp[i] == '(' || exp[i] == '[') {
s.push(exp[i]);
continue;
} else if(exp[i] == '}' || exp[i] == ')' || exp[i] == ']') {
if(s.top() == exp[i]) {
cout << "bracket matched popping " << s.top() << endl;
s.pop();
continue;
} else {
cout << "bracket dose not matched" << endl;
break;
}
} else {
continue;
}
}
}