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

费解 哪里出错了 那位大侠帮忙指正下吧~

Posted by callmewhy at 2009-03-14 14:36:15 on Problem 1068
#include<iostream>
using namespace std;

char p[10000],s[20000]; 

int main()
{
        
   int t,n,ip=1,NumW,is=1,i;
   cin>>t;
    
                                                           
   int left=0,right=0;
   while(t!=0)
   {
      cin>>n;  
      
      
      memset(p, '0', sizeof(p));
	  for(i=1; i<n+1; i++)
	        cin>>p[i];
   
      memset(s, '(', sizeof(s));
      
      is=0;
      for(ip=1; ip<n+1; ip++)
      {                             
            NumW=p[ip]-p[ip-1];            
            is = is + NumW + 1;
            s[is] = ')';   
       }      
   
      
     // p[0]=p[1];     
      ip=n; 
      for(is = 2*n;is>0;is--)//利用左右括号个数相等 
      {
         if(s[is]==')')
         {
                i=is; left=0;right=0;
                do{
                    if(s[i]=='(')              left++;
                    else if(s[i]==')')           right++;
                    i--;
                   }while((right-left)!=0);
                              
                
                p[ip]=right+'0';
                ip--;
         }
       }
       p[1]='1';
       for(i=1; i<=n; i++)
              cout<<p[i]<<" ";
       cout<<endl;
      
      t--;       
     }    
    
      
    system("pause");
    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