| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
求助#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int k1,k2,ans;
int main()
{
char a[105];
scanf("%s",&a);
while(a[0]!='e')
{
k1=0;
k2=0;
ans=0;
for(int i=0;;i++)
{
if(a[i]=='(')
k1++;
else if(a[i]=='[')
k2++;
else if(a[i]==')')
{
if(k1)
{
k1--;
ans++;
}
}
else if(a[i]==']')
{
if(k2)
{
k2--;
ans++;
}
}
else
break;
a[i]=0;
}
printf("%d\n",2*ans);
scanf("%s",&a);
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator