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

Re:这题不会递归,用栈写的,居然过了,表明我是多么的弱!以下是我的输入:

Posted by Ontheline at 2009-05-15 22:08:27 on Problem 1145
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:
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