| ||||||||||
| 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 | |||||||||
我的程序好象没问题,但结果总是Wrong answer请高人指点。
#include <stdio.h>
int main()
{
char a[101];
while(scanf("%s",a)&&a[0]!='e')
{
int i = 0,j = 0,s = 0,k = 0; // char b[101];
while(a[i])
{
if(a[i]=='('||a[i]=='[')
{
a[j++] = a[i];
}
else if(a[i]==')')
{
for(k=j-1;k>=0;--k)
if(a[k]=='(')
{
++s;
j = k;
break;
}
}
else
{
for(k=j-1;k>=0;--k)
if(a[k]=='[')
{
++s;
j = k;
break;
}
}
++i;
}
printf("%d\n",2*s);
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator