Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

我的程序好象没问题,但结果总是Wrong answer

Posted by yujianhua at 2006-08-10 19:46:30
请高人指点。

#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator