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> 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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator