| ||||||||||
| 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 | |||||||||
谁能帮忙看看#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator