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

谁能给我点测试数据啊。总是WA啊。。。

Posted by xax10000 at 2005-07-10 18:17:36 on Problem 1400
#include<iostream>
#include<string>
using namespace std;
string str;
bool  panB(int beg,int end, bool *a)
{
	if(beg==0)return 1;
	int i;
	for(i=beg-1;i>=0;--i)if(str[i]!=' ')break;
	if(i<0)return 1;
	if(str[i] == '('|| str[i]== '+' ) return 1;
	if(str[i] == '/')return 0;
 	if(a[0]||a[1])return 0;
	else return 1;
}
bool panE(int beg,int end,bool *a)
{
	if(end==str.size()-1)return 1;
	int i;
	for(i=end+1;i<str.size();++i)if(str[i]!=' ')break;
	if(i>=str.size())return 1;
	if(str[i]=='+'||str[i]=='-')return 1;
 	if(a[0]||a[1])return 0;
	else return 1;
}
int main(int argc, char* argv[])
{
	int n, i, j, flag1, flag2; 
	cin>>n;
	while(n--)
	{
		cin>>str;
		int count = 0;
		for(i=0;i<str.size();++i)
		{
			bool fhao[2] = {0};
			if(str[i]=='(')
			{
				flag1 = i;
			    count ++;
				for(j=i+1;j<str.size();++j)
				{
					if(str[j]=='(')
					    count++;
				    if(str[j]==')')
					{
						count --;
					    if(!count)
						{
							flag2 = j;
					        break;
						}
					}
					if(count==1)
					{
						if(str[j]=='+') fhao[0] = 1;
						if(str[j]=='-') fhao[1] = 1;
					}
				}
			}
			else continue;
		    if(panB(flag1,flag2,fhao) && panE(flag1,flag2,fhao))
			{
				str[flag1] = ' ';
				str[flag2] = ' ';
			}
		}
		for(i=0;i<str.size();++i)
		{
			if(str[i]==' ')continue;
			cout<<str[i];
		}
		cout<<endl;
	}
	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