标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 101 Accepted Submission(s): 49
1 #include<stdio.h> 2 #include<stack> 3 using namespace std; 4 const int MAXN=1100; 5 char m[MAXN]; 6 int main(){ 7 int T; 8 scanf("%d",&T); 9 while(T--){ 10 stack<char>st; 11 scanf("%s",m); 12 int k=0; 13 for(int i=0;m[i];i++){ 14 if(m[i]==‘(‘)st.push(m[i]); 15 else if(!st.empty())st.pop(),k++; 16 } 17 printf("%d\n",k); 18 } 19 return 0; 20 }
标签:
原文地址:http://www.cnblogs.com/handsomecui/p/4841414.html