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 ytmsdy at 2008-08-15 13:20:56 on Problem 1690 and last updated at 2008-08-15 13:22:19
这是我的程序,看看有什么bug不??
#include<iostream>
using namespace std;
int main()
{
	char word_1[300],word[300];
	int num,i,j,k,l;
	int len;
	int flag[300];
	scanf("%d",&num);
	getchar();
	while(num--)
	{
		gets(word_1);
		len=strlen(word_1);
		j=0;
		for(i=0;i<len;i++)
		{
			if(word_1[i]==' ')
			continue;
			word[j]=word_1[i];
			j++;
		}
		word[j]='\0';
		len=strlen(word);
		memset(flag,0,sizeof(flag));
		for(i=len-1;i>=0;i--)
		{
			if(word[i]=='('&&word[i+2]==')')
			{
				flag[i+2]=1;
				word[i]='~';
				word[i+2]='~';
				continue;
			}
			if(word[i]=='('&&(	word[i-1]=='+'	||	i==0	||	word[i-1]=='('	))
			{
				j=i+1;
				while(1)
				{
					if(word[j]==')'&&flag[j]==0)
						break;
					j++;
				}
				flag[j]=1;
				word[i]='~';
				word[j]='~';
			}
			if(word[i]=='('&&word[i-1]=='-')
			{
				int temp=0;
				j=i+1;
				while(1)
				{
					if(word[j]==')')
						break;
					j++;
					if(word[j]=='+'||word[j]=='-')
						temp++;
				}
				if(temp==0)
				{
					word[i]='~';
					word[j]='~';
					flag[j]=1;
				}
			}
		}
		for(i=0;i<len;i++)
		{
			if(word[i]=='~')
				continue;
			printf("%c",word[i]);
		}
		printf("\n");
	}
	
	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