Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <stack>
- using namespace std;
- int main()
- {
- string s;
- cin >> s;
- string otkr = "([{<";
- string zakr = ")]}>";
- int n = s.length();
- stack <char> st;
- bool f = true;
- for (int i = 0; i < n; i++){
- if (otkr.find(s[i]) != -1)
- st.push(s[i]);
- if (zakr.find(s[i]) != -1){
- if (st.empty()){
- f = false;
- break;
- }
- if (zakr.find(s[i]) == otkr.find(st.top()))
- st.pop();
- else{
- f = false;
- break;
- }
- }
- }
- if (st.empty() && f)
- cout << "da";
- else
- cout << "net";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement