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

谁能帮忙看看

Posted by ccnuzhang at 2008-04-30 19:43:07 on Problem 1690
#include <iostream>
#include <cstring>

using namespace std;

int main()
{
	short T,len,op,i,j,n,num;
	char str[260],s[260];
	cin>>T;
	fflush(stdin);
	while(T--)
	{
		gets(str);
		len=strlen(str);
		for(i=0,j=0,op=0,n=0,num=0;i<len;i++)
		{
			if(str[i]==' ') continue;
			else if(str[i]=='-') op=1;
			else if(str[i]=='(' && op==0) continue;
			else if(str[i]==')' && n==0 ) continue;
			else 
			{
				op=0;
				if( ( str[i]<='Z' && str[i]>='A' )||(str[i]<='z' && str[i]>='a' ) )
					num++;
			}
			if(str[i]==')') 
			{
					n--;
				if(num==1)
				{
					s[j-2]=s[j-1];
					j--;
					num=0;
					continue;
				}
			
			}
			else if(str[i]=='(') 
			{
				n++;
				op=0;
				num=0;
			}
			s[j++]=str[i];
		}
		s[j]='\0';
		cout<<s<<endl;
	}
	return 12;
}

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