((((B)()))()) (B)
4 1
#include<stdio.h>
#include<string.h>
#include<stack>
using namespace std;
char gift[1100];
int main()
{
int i,j;
int len;
while(scanf("%s",gift)!=EOF)
{
len=strlen(gift);
stack<char>s;
for(i=0;i<len&&gift[i]!='B';i++)
{
if(s.empty())
s.push(gift[i]);
else
{
if(s.top()=='('&&gift[i]==')')
s.pop();
else
s.push(gift[i]);
}
}
printf("%d\n",s.size());
}
return 0;
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
原文:http://blog.csdn.net/wangluoershixiong/article/details/47088681