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 |
Re:这题不会递归,用栈写的,居然过了,表明我是多么的弱!以下是我的输入:In Reply To:这题不会递归,用栈写的,居然过了,表明我是多么的弱!以下是我的输入: Posted by:Ontheline at 2009-05-15 22:06:27 while(scanf("%d",&N)!=EOF) { str=""; r=l=0; gets(temp); str+=temp; for(i=0;i<str.size();i++) { if(str[i]=='(')l++; else if(str[i]==')')r++; } while(l>r) { gets(temp); str+=temp; for(i=0;i<strlen(temp);i++) { if(temp[i]=='(')l++; else if(temp[i]==')')r++; } } j=0; for(i=0;i<str.size();i++) { if(str[i]!='\n' && str[i]!=' ' && str[i]!='\t') temp[j++]=str[i]; } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator