Answers for "Copy and paste your answer to the assignment on Upgraded Balanced Parentheses at the IDE found at the left."

0

Copy and paste your answer to the assignment on Upgraded Balanced Parentheses at the IDE found at the left.

#include <iostream>
#include <string>
#include <vector>
#include <stack>
using namespace std;


int main()
{
	string x;
	stack < char, vector<char> > iStack;

    cout << "Enter series of parentheses: ";
    getline(cin, x);

    for (int i=0; i<x.length(); i++)
      if (x[i] == '(' || x[i] == '{' || x[i] == '[')
          iStack.push(x[i]);
      else
      {
        cout << iStack.top() << endl;
        iStack.pop();
      }

    if (iStack.empty())
        cout << "Balance!" << endl;
    else
        cout << "Not Balance!" << endl;
}
Posted by: Guest on October-17-2021

Code answers related to "Copy and paste your answer to the assignment on Upgraded Balanced Parentheses at the IDE found at the left."

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language