Writing Algorithms Every Day (Queue) A Gift for April Fools' Day

This topic has been opened before, which is to see (the amount that is not offset before B appears.

Code:

#include<iostream>
#include<cstdio>
#include<string.h>
#include<stack>
#include<queue>
#include<queue>
using namespace std ;
#define MAX 400
int main(){
  string s ;
  while(cin >> s) {
    queue<char> qe;
    int num =0;
    for (int i = 0 ; i <strlen(s.c_str());i++)
    {
        if(s[i]=='B')
        {
            break;
        }
        if(s[i]=='(')
        {
            qe.push ('(');
        }
        if(s[i]==')')
            if(!qe.empty())
                qe.pop();
    }
    cout << qe.size()<<endl;
  }
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325566206&siteId=291194637