id
int32 0
32.5k
| code
stringlengths 95
8.4k
| label
stringclasses 65
values |
---|---|---|
8,100 |
void fun(char a[])
{
int len,i,j,n,bi=0,zuo,you,hao=0;
char b[200];
int c[200];
len=strlen(a);
for(j=0;j<len;j++)
{
if(a[j]=='('||a[j]==')')
{
b[bi]=a[j];
c[bi]=j;
bi+=1;
}
}
for(j=0;j<bi-1;j++)
{
if(b[j]=='('&&b[j+1]==')')
{
zuo=j;
you=j+1;
hao=1;
break;
}
}
if(hao==0)
return;
while(b[zuo]=='('&&b[you]==')')
{
b[zuo]=1;
b[you]=1;
zuo-=1;
you+=1;
}
for(j=0;j<bi;j++)
{
if(b[j]==1)
{
a[c[j]]=1;
}
}
fun(a);
}
int main()
{
int i,n,len,j;
char a[200];
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%s",a);
len=strlen(a);
puts(a);
fun(a);
for(j=0;j<len;j++)
{
if(a[j]!='('&&a[j]!=')')
printf(" ");
else if(a[j]=='(')
printf("$");
else if(a[j]==')')
printf("?");
}
printf("\n");
}
return 0;
}
| 17 |
8,101 | //#include<math.h>
int main()
{
char st[101];
int g[101];
int len,i,j,left;
while (scanf("%s",st)!=EOF)
{
printf("%s\n",st);
len=strlen(st);
left=0;
for (i=0;i<len;i++)
{
if (st[i]=='(')
{
left++;
g[left]=i;
}
}
for (i=left;i>0;i--)
{
for (j=g[i]+1;j<len;j++)
if (st[j]==')')
{
st[g[i]]=' ';
st[j]=' ';
break;
}
}
for (i=0;i<len;i++)
{
if (st[i]==')') printf("?");
else if (st[i]=='(') printf("$");
else printf(" ");
}
printf("\n");
}
return 0;
}
| 17 |
8,102 | char st[100];
char st2[100];
int main()
{
memset(st,0,100);
memset(st2,0,100);
while(cin>>st)
{
int left=0,right=0;
int len=strlen(st);
for(int i=0;i<len;i++)
{
if(st[i]=='(')
left++;
if(st[i]==')')
right++;
if(left<right)
{
st2[i]='?';
right--;
}
}
left=0;
right=0;
for(int j=len-1;j>=0;j--)
{
if(st[j]=='(')
left++;
if(st[j]==')')
right++;
if(left>right)
{
st2[j]='$';
left--;
}
}
for(int i=0;i<len;i++)
{
if(st2[i]!='$'&&st2[i]!='?')
st2[i]=' ';
}
cout<<st<<endl;
cout<<st2<<endl;
memset(st,0,100);
memset(st2,0,100);
}
return 0;
} | 17 |
8,103 | char s[101];//?????????????
int l;//??????
int f(int k){//????
int i,j;
for(i = k;i >= 0;i--)//??????
if(s[i] == '(')
{
for(j = i + 1;j < l;j++)
if(s[j] == ')')//????????????
{
s[i] = 'a';//?????????
s[j] = 'a';
k = i;
return f(k);//??
}
}
for(i = 0;i < l;i++)//??
{
if(s[i] == '(')
cout << '$';
else if(s[i] == ')')
cout << '?';
else
cout << ' ';
}
cout << endl;
return 0;
}
int main(){
while(scanf("%s",s)!=EOF){
l = strlen(s);
cout << s << endl;
f(l - 1);//????
}
return 0;
}
| 17 |
8,104 | void main()
{
int i,j,k,u,p;
char c;
for(;;)
{
p=1;
char ch[102]={'0'};
i=2;
c=getchar();
if(c==-1)
break;
else
ch[1]=c;
while((c=getchar())!='\n')
{
ch[i]=c;
i++;
}
i--;
for(j=1;j<=i;j++)
printf("%c",ch[j]);
printf("\n");
while(p==1)
{
p=0;
for(j=1;j<=i-1;j++)
{
if(ch[j]=='(')
{
for(k=j+1;k<=i;k++)
{
u=1;
if(ch[k]=='(')
{
break;
}
else
{
if(ch[k]==')')
{
u=0;
break;
}
}
}
if(u==0)
{
ch[j]=0;
ch[k]=0;
p=1;
}
}
}
}
for(j=1;j<=i;j++)
{
if(ch[j]=='(')
{
ch[j]='$';
}
else
{
if(ch[j]==')')
{
ch[j]='?';
}
else
ch[j]=' ';
}
}
for(j=1;j<=i;j++)
printf("%c",ch[j]);
printf("\n");
}
} | 17 |
8,105 | char a[101]={0};
int zuo[101]={0};
int n=0;
void change(int x)
{
if (a[x]!=0)
{
if (a[x]=='(')
{
zuo[++n]=x;
}
else if (a[x]==')')
{
if (n>0)
{
a[x]=' ';
a[zuo[n--]]=' ';
}
}
else
a[x]=' ';
change (x+1);
}
}
int main()
{
while (cin>>a)
{
cout<<a<<endl;
n=0;
change (0);
for (int i=0;a[i]!=0;i++)
{
if (a[i]=='(')
cout<<"$";
else if (a[i]==')')
cout<<"?";
else
cout<<a[i];
}
cout<<endl;
}
return 0;
} | 17 |
8,106 | char s[100];
char a[100];
int b[100];
int num=0;
int i,j;
void f()
{
for(i=0;i<strlen(s);i++)//?a[i]??????
{
a[i]=' ';
}
for(i=0;i<strlen(s);i++)
{
if(s[i]=='(')//?s[i]=='('
{
b[num]=i;//?b[num]?????
a[i]='$';//?a[i]??'$'
num++;//num?1
}
else if(s[i]==')'&&num>0)//?s[i]==')'&&num>0
{
num--;//num?1
a[b[num]]=' ' ;//?a[b[num]]????
}
else if(s[i]==')'&&num<=0)//?s[i]==')'&&num<=0
a[i]='?';//?a[i]???
}
for(i=0;i<strlen(s);i++)
{
cout<<a[i];//??a[i]
}
cout<<endl;
}
int main()
{
while(cin>>s)
{
num=0;
cout<<s<<endl;
f();
}
}
| 17 |
8,107 | int main(){
int n;
scanf("%d", &n);
char a[200];
char b[200];
int c[200];
int len;
int k;
for (int i = 0; i<n; i++)
{
scanf("%s", a);
len = strlen(a);
k = 0;
int j = 0;
for (j = 0; j<len; j++)
{
if (a[j] == '(')
{
b[j] = '$';
c[k] = j;
k = k + 1;
}
else if (a[j] == ')')
{
if (j == 0)
{
b[j] = '?';
}
else
{
if (k > 0 && b[c[k - 1]] == '$')
{
b[c[k - 1]] = ' ';
b[j - 1] = ' ';
b[j] = ' ';
k = k - 1;
}
else
{
b[j] = '?';
c[k] = j;
k = k + 1;
}
}
}
else
{
b[j] = ' ';
}
}
b[j] = '\0';
printf("%s\n", a);
printf("%s\n", b);
}
return 0;
} | 17 |
8,108 | int main()
{
char chuan[101],shuchu[100];
int count1,count2,length,i,j;
while(cin>>chuan)
{
cout<<chuan<<endl;
length=strlen(chuan);//?????
strcpy(shuchu,chuan);//????????????????
count1=0;
count2=0;
for(i=0;i<length;i++)
{
if(chuan[i]=='(')count1++;
if(chuan[i]==')')
{
count2++;
if(count2>count1)
{
shuchu[i]='?';
count2--;
}//??????????????????????????????
}
}//?????????
count1=0;
count2=0;
for(i=length-1;i>=0;i--)
{
if(chuan[i]==')')count2++;
if(chuan[i]=='(')
{
count1++;
if(count1>count2)
{
shuchu[i]='$';
count1--;
}//??????????????????????????????
}
}//?????????
shuchu[length]='\0';
for(i=0;i<length;i++)
{
if(shuchu[i]!='?' && shuchu[i]!='$')shuchu[i]=' ';
}//?????????
cout<<shuchu<<endl;
memset(shuchu,0,sizeof(shuchu));
memset(chuan,0,sizeof(chuan));
}
return 0;
} | 17 |
8,109 | char * mystrrchr(char * strcopy, char * end)
{
char * tmp = end-1;
while(tmp>=strcopy)
{
if(*tmp=='(')
{
return tmp;
}
tmp--;
}
return NULL;
}
void judge(char * str,char * flag)
{
char strcopy[101];
strcpy(strcopy,str);
int len=strlen(strcopy);
char * index1=strchr(strcopy,')');
while(index1!=NULL&&(index1-strcopy)<len)
{
char * index2=mystrrchr(strcopy,index1);
if(index2!=NULL)
{
strcopy[index1-strcopy]='-';
strcopy[index2-strcopy]='-';
}
index1=strchr(index1+1,')');
}
int i=0;
for(i=0;i<len;i++)
{
if(strcopy[i]=='(')
flag[i]='$';
if(strcopy[i]==')')
flag[i]='?';
}
printf("%s\n%s\n",str,flag);
}
int main()
{
int n=0;
scanf("%d",&n);
getchar();
char str[101];
char flag[101];
while(n>0)
{
memset(flag,' ',sizeof(flag));
gets(str);
flag[strlen(str)]='\0';
judge(str,flag);
n--;
}
return 0;
}
| 17 |
8,110 | /* Name : ???????????
* Version : 2.0
* Date : 2012-11-24
* New : Null
* Func&Feat :
* State : Design
*/
int pairs(int,int,char text[],char match[]);
int main()
{
for(;;)
{
char text[101]={0},match[101]={0}; //???text????????match??????
int lgth=0; //???lgth??text???brkt[]????????????-1??????1?
gets(text); //??gets()??????????????????????
if(text[0]==0)break; //????????????????????
for(int i=0;i<101;i++) //???????text?????????????
{
if(text[i]!=0)
{
if(text[i]=='(')match[i]='$'; //??text[]?????brkt[]???-1?match[]????'$'
else if(text[i]==')')match[i]='?';//??text[]?????brkt[]???1?match[]????'?'
else match[i]=' '; //??text[]?????brkt[]?????0?match[]??????
}
else //??text[]?????????text?????
{
lgth=i;
break;
}
}
pairs(0,0,text,match);
cout<<text<<endl<<match<<endl;
}
return 0;
}
int pairs(int n,int hemi,char text[],char match[])
{
for(;;)
{
char c=text[n];
if(c==0)return -1;
if(c=='(')
{
int l=n;
int r=pairs(n+1,1,text,match);
// cout<<l<<' '<<r<<endl;
if(r!=-1)
{
match[l]=match[r]=' ';
n=r+1;
}
else return -1;
}
else if(c==')'&&hemi==1)return n;
else n++;
}
}
| 17 |
8,111 |
int main()
{
char a[101] = {'\0'}, b[101] = {'\0'};
int i, j;
while (cin.getline(a, 101))
{
for (i = 0;i < 101; i++)
{
if (a[i] == '\0')
break;
if (a[i] == '(')
b[i] = '$';
else if (a[i] == ')')
b[i] = '?';
else
b[i] = ' ';
if (a[i] == ')')
{
for (j = i; j >= 0; j--)
{
if (a[j] == '(' && b[j] == '$')
{
b[i] = ' ';
b[j] = ' ';
break;
}
}
}
}
cout << a << endl;
cout << b << endl;
for (i = 0; i < 101; i++)
{
a[i] = '\0';
b[i] = '\0';
}
}
return 0;
} | 17 |
8,112 | int main()
{
char a[110];
int l,i,j,p=0;
while(scanf("%s",a)!=EOF)
{
printf("%s\n",a);
l=strlen(a);
for(i=0;i<l;i++)
{
p=0;
if(a[i]=='(')
{
for(j=i;j<l;j++)
{
if(a[j]=='(')
p++;
if(a[j]==')')
p--;
if(p==0)
break;
}
if(p!=0)
a[i]='$';
else
a[i]=' ';
}
}
for(i=l-1;i>=0;i--)
{
p=0;
if(a[i]==')')
{
for(j=i;j>=0;j--)
{
if(a[j]==')')
p++;
if(a[j]==' ')
p--;
if(p==0)
{break;}
}
if(p!=0)
a[i]='?';
else
a[i]=' ';
}
}
for(i=0;i<l;i++)
{
if(a[i]!='?'&&a[i]!='$')
a[i]=' ';
}
puts(a);
}
return 0;
} | 17 |
8,113 |
int main()
{
char a[100]={0 };
while(cin>>a)
{
cout<<a<<endl;
int l=strlen(a);
for(int i=0;i<l;i++)
{
switch(a[i])
{
case '(':
a[i]='$';
break;
case ')':
a[i]='?';
break;
default:
a[i]=' ';
}
if(i>l)
break;
}
for(int i=0;i<l;i++)
{
if(a[i]=='$')
for(int j=i+1;j<l;j++)
{
if(a[j]=='?')
{
a[i]=a[j]=' ';
break;
}
if(a[j]=='$')
break;
}
if(a[i]=='?')
for(int j=i-1;j>=0;j--)
{
if(a[j]=='$')
{
a[i]=a[j]=' ';
break;
}
if(a[j]=='?')
break;
}
}
for(int i=0;i<l;i++)
cout<<a[i];
cout<<endl;
for(int i=0;i<100;i++)
a[i]=0;
}
}
| 17 |
8,114 | int main()
{
char s[101];
char kuohao[101]={0};
int i,j,len;
char ch;
while(scanf("%s",s)>0){
for(i=0; ;i++){
if(s[i]=='(') kuohao[i]=1;
else if(s[i]==')'){
for(j=i;j>=0;j--){
if(kuohao[j]==1){
kuohao[j]=0;
break;
}
}
if(j<0) kuohao[i]=3;
}
else if(s[i]=='\0') break;
}
printf("%s\n",s);
len=strlen(s);
for(i=0;i<len;i++){
if(kuohao[i]==0) printf(" ");
else if(kuohao[i]==1) printf("$");
else if(kuohao[i]==3) printf("?");
}
printf("\n");
for(i=0;i<len;i++) kuohao[i]=0;
}
return 0;
}
| 17 |
8,115 | main()
{
char s[101];
int i,a[101],j,l;
while((scanf("%s",s))!=EOF)
{
j=0;
puts(s);
l=strlen(s);
for(i=0;i<l;i++)
{
if(s[i]=='(') a[++j]=i;
else if(s[i]==')')
{
if(j)
{
s[i]=' ';
s[a[j]]=' ';
j--;
}
else s[i]='?';
}
else s[i]=' ';
}
for(i=1;i<=j;i++) s[a[i]]='$';
puts(s);
}
}
| 17 |
8,116 |
int main(){
int n,i,j,k,l;
char as[110],bs[110],cs[110];
for(k=0;;k++)
{
scanf("%s",as);
int len=strlen(as);
if(strcmp(as,bs)==0)
break;
strcpy(bs,as);
for(i=0;i<len;i++)
cs[i]=' ';
cs[len]=0;
for(l=0;l<len;l++)
{
for(i=l;i<len;i++)
{
if(as[i]==')')
{
for(j=i;j>=0;j--)
{
if(as[j]=='(')
{
as[i]=' ';
as[j]=' ';
j=0;
i=0;
}
}
}
}
}
for(i=0;i<len;i++)
{
if(as[i]=='(')
cs[i]='$';
else if(as[i]==')')
cs[i]='?';
}
printf("%s\n%s\n",bs,cs);
strcpy(bs,as);
}
return 0;
} | 17 |
8,117 | main()
{
int i,j,k,len=0;
char a[1000];
char b[1000];
while(gets(a)!=NULL)
{
len=strlen(a);
for(i=0;i<len;i++)
{
b[i]='c';
}
b[i]='\0';
for(i=len-1;i>=0;i--)
{
if(a[i]!='('&&a[i]!=')')
b[i]=' ';
else if(a[i]==')'&&b[i]!=' ')
b[i]='?';
else if(a[i]=='(')
{
if(i==len-1)
b[i]='$';
else
{
for(j=i+1;j<len;j++)
{
if(a[j]==')'&&b[j]!=' ')
{b[j]=' ';b[i]=' ';break;}
}
if(j==len)
b[i]='$';
}
}
}
//puts(a);
//puts(b);
for(i=0;a[i]!='\0';i++)
{printf("%c",a[i]);}
printf("\n");
for(i=0;a[i]!='\0';i++)
{printf("%c",b[i]);}
printf("\n");
}
getchar();
getchar();
}
| 17 |
8,118 | int main()
{
char a[200];
while(cin.getline(a, 200))
{
int n = strlen(a);
int k;
cout<<a<<endl;
for(int i = 0; i < n; i++)
{
if(a[i] == '?')
a[i]=' ';
if(a[i] == '$')
a[i]=' ';
if(a[i] == ')')
{
for( k = i-1; k>=0;k--)
{
if(a[k] == '(')
{
a[i] = ' ';
a[k] = ' ';
break;
}
}
if(k < 0)
a[i] = '?';
}
}
for(int i = 0; i < n; i++)
{
if(a[i] == '(')
a[i] = '$';
else
if(a[i] != '?')
a[i] = ' ';
}
cout<<a<<endl;
}
return 0;
}
| 17 |
8,119 | // ??????.cpp : Defines the entry point for the console application.
//
int main(int argc, char* argv[])
{
char zfc[120],cha,i,j,len;
while(scanf("%s",zfc)!=EOF){
cha=0;
len=strlen(zfc);
printf("%s\n",zfc);
for(i=0;i<len;i++){
if(zfc[i]!='('&&zfc[i]!=')'){
zfc[i]=' ';
}
if(zfc[i]==')'){
for(j=i-1;j>=0;j--){
if(zfc[j]=='('){
zfc[j]=' ';
zfc[i]=' ';
break;
}
}
if(j<0){
zfc[i]='?';
}
}
}
for(i=0;i<len;i++){
if(zfc[i]=='('){
zfc[i]='$';
}
}
puts(zfc);
}
return 0;
}
| 17 |
8,120 | //
// main.cpp
// ()pipei
//
// Created by ? ?? on 13-12-4.
// Copyright (c) 2013? LEE. All rights reserved.
//
char s[10000];//??????????????????
int countl,countr,sum[1000]={0};
//?????????????????????
int pipei(int i)
{
if(s[i]=='\0') return sum[i]=0;
if(s[i]=='(')
{ ++countl;
pipei(i+1);sum[i]+=sum[i+1];
if(sum[i]>0)
//????????????>0????
{s[i]=' ';countl--;countr--;sum[i]--;}
//??????1
else {countl--;s[i]='$';}//????
return 0;
}
else if(s[i]==')')
{countr++;sum[i]++;
if(countl>=countr)
{s[i]=' ';//????????
pipei(i+1);
sum[i]+=sum[i+1];//????????????????
return 0; }
else {countr--;s[i]='?';pipei(i+1);
sum[i]+=sum[i+1];return 0;}
//??????????????1????????
}
else//?????????
{ s[i]=' ';
pipei(i+1);
sum[i]+=sum[i+1];
return 0;
}
return 0;
}
int main()
{
while(cin)//?????????
{
cin.getline(s,1000);//??????
cout<<s<<endl;
pipei(0);
cout<<s<<endl;
countl=countr=0;memset(sum,0,sizeof(sum));
//???????????????0
}
return 0;
} | 17 |
8,121 | int main()
{
int i,j,len;
char a[101];
while(cin>>a)
{
int b[100]={0};
len=strlen(a);
for(i=0;i<len;i++)
{
if(a[i]==')')
{
char *p=&a[i-1];
for(j=i-1;j>=0;j--)
{
if(*p=='('&&b[j]==0)
{
b[j]=1;b[i]=1;
break;
}
p--;
}
}
}
cout<<a<<endl;
for(i=0;i<len;i++)
{
if(a[i]=='('&&b[i]==0)
cout<<"$";
else
{
if(a[i]==')'&&b[i]==0)
cout<<"?";
else
cout<<" ";
}
}
cout<<endl;
}
return 0;
}
| 17 |
8,122 | char s[999];
int find(int i,int l)
{
int t;
if(s[i]=='\0') return -1;
if(s[i]=='(')
{
t=find(i+1,l+1);
if(t==-1) s[i]='$';
else s[i]=' ';
if(t==-1) return -1;
else return find(t+1,l);
}
if(s[i]==')')
{
if(l==0) s[i]='?';
else s[i]=' ';
if(l==0) return find(i+1,0);
else return i;
}
s[i]=' ';
return find(i+1,l);
}
int main()
{
for(;cin>>s;)
{
cout<<s<<endl;
find(0,0);
cout<<s<<endl;
}
return 0;
}
| 17 |
8,123 | int main()
{
char str[110];
int i=0,j=0;
while(cin.getline(str,110))
{
for(i=0;str[i]!='\0';i++) //???????
{
cout<<str[i];
}
cout<<endl;
for(i=0;str[i]!='\0';++i) //????????????????????????????????????
{
if(str[i]==')')
{
for(j=i-1;j>=0;--j)
{
if(str[j]=='(')
{
str[i]=str[j]=' ';
break;
}
}
}
}
for(i=0;i<strlen(str);++i) //??????????????
{
if(str[i]=='(')
cout<<"$";
else if(str[i]==')')
cout<<"?";
else
cout<<" ";
}
cout<<endl;
}
return 0;
} | 17 |
8,124 | int main()
{
void match(char *ps, char *pf, int len);
char a[N] = {'\0'};
while( scanf("%s", a) == 1) {
char b[N] = {'\0'};
match(a, b, strlen(a));
}
return 0;
}
void match(char *ps, char *pf, int len)
{
int i, flag, last, isleft, isright;
char str[N] = {'\0'}, strf[N] = {'\0'};
strcpy(strf, pf);
strcpy(str, ps);
for(i = 0; i < len; i++) {
if(*(str + i) == '(')
*(strf + i) = -1;
else if( *(str + i) == ')' )
*(strf + i) = +1;
}
do {
flag = 0;
last = 0;
isleft = 0;
isright = 0;
for(i = 0; i < len; i++) {
if (*(strf + i) == 1 && flag == 1) {
*(strf + i) = 0;
*(strf + last) = 0;
flag = 0;
isleft = 1;
} else if(*(strf + i) == -1) {
flag = 1;
last = i;
isright = 1;
}
}
} while(isleft && isright);
printf("%s\n", ps);
for(i = 0; i < len; i++) {
if (*(strf + i) == -1)
printf("$");
else if (*(strf + i) == +1)
printf("?");
else
printf(" ");
}
printf("\n");
}
| 17 |
8,125 | int main()
{
char a[500],b[500]={0};
int n,i,k,j,jud[500]={0},max=0;
for(i=0;i<500;i++)
{
a[i]=0;jud[i]=0;
}
while(scanf("%s",a)!=EOF)
{
for(i=0;i<500;i++)
{
b[i]=0;
}
for(i=0;i<strlen(a);i++)
{
b[i]=' ';
}
for(i=0;i<strlen(a);i++)
{
if(a[i]==')')
{
for(j=i-1;j>=0;j--)
{
if(a[j]=='('&&jud[j]==0)
{
jud[j]=1;
jud[i]=1;
break;
}
}
}
}
for(i=0;i<strlen(a);i++)
{
if(a[i]=='('&&jud[i]==0)
{
b[i]='$';
}
if(a[i]==')'&&jud[i]==0)
{
b[i]='?';
}
}
printf("%s\n%s\n",a,b);
for(i=0;i<500;i++)
{
a[i]=0;jud[i]=0;
}
}
} | 17 |
8,126 | int main()
{
char a[101]={0};
char b[101];
int i,j,k;
int l,r;
int len;
while(cin>>a)
{
l=0;r=0;
for(i=0;i<101;i++)
{
if(a[i]==0)
{
len=i;
break;
}
}
for(i=0;i<len;i++)
{
b[i]=' ';
}
b[len]=0;
for(i=0;i<len;i++)
{
if(a[i]=='(')
l++;
if(a[i]==')')
l--;
if(l<0)
{b[i]='?';l=0;}
}
for(i=0;i<len;i++)
{
if(a[len-i-1]==')')
r++;
if(a[len-i-1]=='(')
r--;
if(r<0)
{b[len-i-1]='$';r=0;}
}
cout<<a<<endl<<b<<endl;
for(i=0;i<101;i++)
{a[i]=0;}
}
return 0;
} | 17 |
8,127 |
int main()
{
char str[101];
int n,i,j,l,k=0;
char c[101];
cin >> n;
for(i=1;i<=n;i++)
{
int left=0,right=0;
int e[101]={0};
cin >> str;
l=strlen(str);
for(j=0;j<l;j++)
{
if(str[j]=='(')
{
left++;
e[j]=1;
c[left]=j;
}
if(str[j]==')')
{
if(left==0)
{
e[j]=2;
}
else
{
e[c[left]]=0;
left--;
}
}
else
continue;
}
cout << str << endl;
for(j=0;j<l;j++)
{
if(e[j]==1)
cout << "$";
else if(e[j]==2)
cout << "?" ;
else
cout << " " ;
}
cout << endl;
}
return 0;
} | 17 |
8,128 | static char c[2][101];
int i,n;
void search(int a)
{
for(i++;i<n;i++)
if(c[0][i]==')')
{
c[1][a]=' ';
c[1][i]=' ';
break;}
else if(c[0][i]=='(')
search(i);
else c[1][i]=' ';
if(i>=n)
c[1][a]='$';
}
int main()
{
while(scanf("%s",&c[0])!=EOF)
{
for(n=0;c[0][n]!='\0';n++);
for(i=0;i<n;i++)
if(c[0][i]==')')
c[1][i]='?';
else if(c[0][i]=='(')
search(i);
else c[1][i]=' ';
puts(c[0]);
puts(c[1]);
for(i=0;i<n;i++)
{
c[0][i]=0;
c[1][i]=0;
}
}
} | 17 |
8,129 | void main()
{
int n,length,k;
scanf("%d",&n);
getchar();
int i;
char a[500];
for(i=1;i<=n;i++)
{
gets(a);
puts(a);
length=strlen(a);
int j;
for(j=length-1;j>=0;j--)
{
int judge=0;
if(a[j]!='('&&a[j]!=')')
a[j]=' ';
else if(a[j]=='(')
{
for(k=j+1;k<length;k++)
{
if(a[k]==')')
{
a[k]=' ';
a[j]=' ';
judge=1;
break;
}
}
if(judge==0)
a[j]='$';
}
}
for(j=0;j<length;j++)
{
if(a[j]==')')
a[j]='?';
}
puts(a);
}
}
| 17 |
8,130 | int main()
{
int i,j,k;
char a[150]={'0'},b[150]={'0'};
for(;~scanf("%s",&a);)
{
i=strlen(a);
for(j=0;j<i;j++) {
if(a[j]=='(') b[j]='$';
else if(a[j]==')') b[j]='?';
else b[j]=' ';
}
for(j=0;j<i;j++)
for(k=j-1;k>=0;k--){
if(b[k]=='$'&&b[j]=='?')
{b[k]=' ';b[j]=' ';}
}
for(k=0;k<i;k++)
printf("%c",a[k]);
printf("\n");
for(k=0;k<i;k++)
printf("%c",b[k]);
printf("\n");
}
return 0;
} | 17 |
8,131 | char a[1000];
int n, c1 = 0;
int match(int c)
{
for(int i = c; i < n; i++)
{
if(a[i] != '(' && a[i] != ')' && a[i] != '$')
a[i] = ' ';
if(a[i] == '(')
{
c1 ++;
if(match(i + 1) != 0)
{
a[i] = ' ';
a[match(i + 1)] = ' ';
c1 --;
}
else
a[i] = '$';
}
if(a[i] == ')')
{
if(c1 == 0)
{
a[i] = '?';
if(i < n)
{
match(i + 1);
return 0;
}
}
return i;
}
}
return 0;
}
int main() //???
{
while(cin>>a)
{
c1 = 0;
n = strlen(a);
cout<<a<<endl;
match(0);
cout<<a<<endl<<endl;
}
return 0;
} //?????
| 17 |
8,132 | int num;
char right(char c)
{ char ch;
if(c!='('&&c!=')')
ch=' ';
else if(c==')')
{ if (num==0) ch='?';
else
{ num--;
ch=' ';
}
}
else
{ num++;
ch=c;
}
return ch;
}
char left(char c,char a)
{ char ch;
if(a==' '||a=='?')
{ ch=a;
if(c==')')num++;
}
else if (num==0) ch='$';
else
{ num--;
ch=' ';
}
return ch;
}
main()
{ int i;
char s[101],a[101];
while(gets(s))
{ num=0;
for(i=0;i<strlen(s);i++)
a[i]=right(s[i]);
num=0;
for(i=strlen(s)-1;i>=0;i--)
a[i]=left(s[i],a[i]);
puts(s);
for(i=0;i<strlen(s);i++)
printf("%c",a[i]);
printf("\n");
}
return 0;
}
| 17 |
8,133 | int main()
{
int n,i,s,j,k;
char c[101];
scanf("%d",&n);
for(i=0;i<n;i++)
{
getchar();
scanf("%s",&c);
s=strlen(c);
printf("%s\n",c);
for(j=0;j<s;j++)
{
if(c[j]!='(' && c[j]!=')')
c[j]=' ';
if(c[j]==')')
{
for(k=j;k>=0;k--)
{
if(c[k]=='(')
{
c[j]=' ';
c[k]=' ';
break;
}
}
}
}
for(j=0;j<s;j++)
{
if(c[j]=='(')
c[j]='$';
if(c[j]==')')
c[j]='?';
}
printf("%s\n",c);
}
return 0;
} | 17 |
8,134 | int len;
void f(char a[])
{
int i,j;
len=strlen(a);
for(i=len-1;i>=0;i--)
{
if(a[i]=='(')
{
for(j=i+1;j<len;j++)
{
if(a[j]==')')
{
a[i]=a[j]=' ';
break;
}
}
if(a[j]=='\0')
{
a[i]='$';
}
f(a);
}
}
}
int main()
{
char c[110]={'\0'};
int i;
while(cin.getline(c,101))
{cout<<c<<endl;
for(i=0;c[i]!='\0';i++)
if(c[i]!='('&&c[i]!=')')
c[i]=' ';//????????????
f(c);
for(i=0;c[i]!='\0';i++)
if(c[i]==')')
c[i]='?';//???????????
cout<<c<<endl;}
return 0;
}
| 17 |
8,135 | void check()
{
char array[103];
while(cin){ //?????
cin.getline(array,103); //?????
int i,j,len;
len=strlen(array); //????
for(i=0;i<len;i++) cout << array[i] ; //??????
cout << endl;
for(i=0;i<len;i++){ //?????????
if(array[i]==')'){ //?????
for(j=i-1;j>=0;j--){ //????????
if(array[j]=='('){ //???
array[j]='1'; //??????
array[i]='1'; //??????
break; //????
}}}}
for(i=0;i<len;i++){ //????????
if(array[i]!='(' && array[i]!=')') cout << ' ';
if(array[i]=='(') cout << '$';
if(array[i]==')') cout << '?';
}
cout << endl;
}
return;
}
int main(){
check(); //??check??
return 0;
}
| 17 |
8,136 | int main()
{
char str1[100][100],str2[100][100]={'\0'};
int i,j,k,l1,l2,t[100],l;
for(i=0;i<100;i++)
{ scanf("%s",str1[i]);
k=strlen(str1[i]);
if(k==0) break;
puts(str1[i]);
l1=0;l2=0;
for(j=0;j<k;j++)
{if(str1[i][j]==')') {t[l2]=j;l2++;}}
for(l=0;l<l2;l++)
{
for(j=t[l];j>=0;j--)
{if(str1[i][j]=='(') {str1[i][t[l]]='A';str1[i][j]='A';break;} }
}
for(j=0;j<k;j++)
{if(str1[i][j]=='(') str2[i][j]='$';
else if(str1[i][j]==')') str2[i][j]='?';
else str2[i][j]=' ';
}
puts(str2[i]);
}
return 0;
} | 17 |
8,137 | int main()
{
char a[101];
int i,num=1,j;
while(cin.getline(a,101))
{
cout<<a<<endl;
for(i=0;a[i]!='\0';i++)
{
num=1;
if(a[i]!=')'&&a[i]!='(')
cout<<" ";
if(a[i]=='(')
{
if(a[i+1]=='\0')
{
cout<<"$";
continue;
}
for(j=i+1;a[j]!='\0';j++)
{
if(a[j]=='(')
num++;
if(a[j]==')')
num--;
if(num==0)
{
cout<<" ";
break;
}
if(a[j+1]=='\0'&&num!=0)
cout<<"$";
}
}
num=1;
if(a[i]==')')
{
if(i==0)
{
cout<<"?";
continue;
}
for(j=i-1;j>=0;j--)
{
if(a[j]==')')
num++;
if(a[j]=='(')
num--;
if(num==0)
{
cout<<" ";
break;
}
if(j==0&&num!=0)
cout<<"?";
}
}
}
cout<<endl;
}
return 0;
} | 17 |
8,138 | int main()
{
char zfc[105];
char sign[105];
char present[105];
while(scanf("%s",zfc)>0)
{
//scanf("%s",zfc);
strcpy(sign,zfc);
strcpy(present,zfc);
int left=0,right=0;
int m=strlen(zfc);
for(int i=0;i<m;i++)
{
if(zfc[i]=='(')
{
left=0;
right=0;
for(int j=i;j<m;j++)
{
if(zfc[j]=='(')
{
left++;
}
if(zfc[j]==')')
{
left--;
}
if(left<=0)
{
break;
}
}
if(left>0)
{
sign[i]='$';
}
}
if(zfc[i]==')')
{
left=0;
right=0;
for(int j=i;j>=0;j--)
{
if(zfc[j]=='(')
{
right--;
}
if(zfc[j]==')')
{
right++;
}
if(right<=0)
{
break;
}
}
if(right>0)
{
sign[i]='?';
}
}
}
for(int i=0;i<m;i++)
{
if(sign[i]!='$'&&sign[i]!='?')
{
sign[i]=' ';
}
}
puts(present);
puts(sign);
}
return 0;
} | 17 |
8,139 | /*
Name: ??????
Copyright:
Author:
Date: 20/11/12 21:21
Description: ????????????100?????????????????
????????????????????????????????????
????????????????????????????????????
????????????????????????????????????
??"$"??,?????????"?"??
*/
int main()
{
char str[100][100]={'\0'};
int m=0;
int i,j,t;//????
int a=0,b=0;//???????
int c[100]={0};
while(cin>>str[m])
{
for(j=0;j<strlen(str[m]);j++)
{
if(str[m][j]=='(')
{
if(j==strlen(str[m])-1)
c[j]=1;
else
{
for(t=j;;t++)
{
if(str[m][t]=='(')
a++;
else if(str[m][t]==')')
b++;
if(t==strlen(str[m])-1||(a==b&&a!=0))
break;
}
if(a>b)// (?????????????
c[j]=1;
a=b=0;
}
}
else if(str[m][j]==')')
{
if(j==0)
c[j]=2;
else
{
for(t=j;;t--)
{
if(str[m][t]=='(')
a++;
else if(str[m][t]==')')
b++;
if(t==0||(a==b&&a!=0))
break;
}
if(a<b)//?????????
c[j]=2;
a=b=0;
}
}
else
continue;
}
cout<<str[m]<<endl;//????????
for(j=0;j<=strlen(str[m])-1;j++)
{
if(c[j]==0)
cout<<' ';//
else if(c[j]==1)
cout<<'$';// ????
else if(c[j]==2)
cout<<'?';// ????
}
cout<<endl;
a=0;
b=0;
for(j=0;j<100;j++)//??
c[j]=0;
m++;
}
return 0;
}
| 17 |
8,140 | int main()
{
char a[110],b[110];
int len,mark,sign=0,s=0;
while(cin.getline(a,110,'\n'))
{
len=strlen(a);
for(int i=0;i<=len-1;i++)
b[i]=a[i];
for(int j=1;j<=len;j++)
{
mark=0;
sign=0;
s=0;
for(int i=0;i<len;i++)
{
if(a[i]=='(')
{
mark=i;
s=1;
}
}
if(mark==len-1)
{
a[mark]='$';
}
if(s!=0)
{
for(int i=mark+1;i<len;i++)
{
if(a[i]==')')
{
a[mark]='a';
a[i]='a';
sign=1;
break;
}
}
}
if(s!=0)
{
if(sign==0)
a[mark]='$';
}
sign=0;
mark=0;
s=0;
for(int i=len-1;i>=0;i--)
{
if(a[i]==')')
{
mark=i;
s=1;
}
}
if(s!=0)
{
if(mark==0)
{
a[mark]='?';
}
}
if(s!=0)
{
for(int i=mark-1;i>=0;i--)
{
if(a[i]=='(')
{
a[mark]='a';
a[i]='a';
sign=1;
break;
}
}
}
if(s!=0)
{
if(sign==0)
a[mark]='?';
}
}
for(int i=0;i<len-1;i++)
cout<<b[i];
cout<<b[len-1]<<endl;
for(int i=0;i<len-1;i++)
{
if(a[i]!='?'&&a[i]!='$')
cout<<' ';
else
cout<<a[i];
}
if(a[len-1]!='?'&&a[len-1]!='$')
cout<<' '<<endl;
else
cout<<a[len-1]<<endl;
memset(a,'\0',sizeof(a));
memset(b,'\0',sizeof(b));
mark=0;
sign=0;
len=0;
}
return 0;
} | 17 |
8,141 | int main()
{
static char c[102],d[102];int i,j,k,s;
while(gets(c))
{puts(c);
for(i=0;c[i]!='\0';i++)
{
if(c[i]=='(')
d[i]=1;
else if(c[i]==')')
d[i]=2;
else d[i]=3;
}
while(1)
{ s=0;
for(j=0;j<=i-2;j++)
{
if(d[j]==1)
break;
}
for(k=j+1;k<=i-1;k++)
{
if(d[k]==2)
{
s=1;
break;
}
}
if(s==0)
break;
for(j=0;j<=i-2;j++)
{ if(d[j]==1)
{
for(k=j+1;k<=i-1;k++)
{ if(d[k]==1)
{
j=k;
}
if(d[k]==2)
{
d[j]=3;
d[k]=3;
break;
}
}
}
}
}
for(k=0;k<=i-1;k++)
{
switch(d[k])
{
case 1:printf("$");break;
case 2:printf("?");break;
case 3:printf(" ");break;
}
}
printf("\n");
}
} | 17 |
8,142 | int main()
{
char line[1000] ;
char outline[1000] ;
int i , j ;
int len ;
while ( cin >> line )
{
strcpy(outline , line) ;
len = strlen(line) ;
for ( i = 0 ; i < len ; i++ )
{
if ( line[i] == ')' )
{
for ( j = i - 1 ; j >= 0 ; j-- )
{
if ( line[j] == '(' )
{
line[j] = ' ' ;
line[i] = ' ' ;
break ;
}
}
}
}
cout << outline << endl ;
for ( i = 0 ; i < len ; i++ )
{
if ( line[i] == '(' )
{
cout << '$' ;
}
else
{
if ( line[i] == ')' )
{
cout << '?' ;
}
else
cout << ' ' ;
}
}
cout << endl ;
}
return 0 ;
}
| 17 |
8,143 | /*
* kuohao.cpp
*?? - 3704:??????
* Created on: 2012-12-6
* Author: ???
*/
int i,j,k,lena;
char a[101];
int main(){
while(cin>>a)
{
cout<<a<<endl;
lena=strlen(a);
for(i=0;i<lena;i++)
{
if(a[i]==')'){
for(j=i;j>=0;j--){
if(a[j]=='('){
a[i]='*';
a[j]='*';
break;
}
}
}
}
for(i=0;i<lena;i++)
{
if(a[i]=='(')
{
a[i]='$';
}
else
if(a[i]==')')
{a[i]='?';
}
else a[i]=' ';
}
cout<<a<<endl;
}
return 0;
} | 17 |
8,144 | char a[1000]={'0'};
char c[1000]={' '};
int qq,pp;
int t=0;
int x(int m)
{
if (qq<=m-1)
{
if (a[qq]=='(')
{
qq++;
t++;
x(m);
}
else if (a[qq]==')')
{
qq++;
t--;
if (t==-1)
{
c[qq-1]='?';
t=0;
}
x(m);
}
else if (a[qq]!='('&&a[qq]!=')')
{
qq++;
x(m);
}
}
t=0;
return 0;
}
int y(int m)
{
if (pp>=0)
{
if (a[pp]==')')
{
pp--;
t++;
y(m);
}
else if (a[pp]=='(')
{
pp--;
t--;
if (t==-1)
{
c[pp+1]='$';
t=0;
}
y(m);
}
else if (a[pp]!='('&&a[pp]!=')')
{
pp--;
y(m);
}
}
t=0;
return 0;
}
int main()
{
char b;
int i=0;
while (cin.get(b))
{
if (b!='\n')
a[i++]=b;
else if (b=='\n')
{
for (int j3=0;j3<=i-1;j3++)
c[j3]=' ';
cout<<a<<endl;
qq=0;
x(i);
pp=i-1;
y(i);
for (int j=0;j<=i-1;j++)
cout<<c[j];
cout<<'\n';
for (int j1=0;j1<=i-1;j1++)
{
c[j1]=' ';
a[j1]='\0';
}
i=0;
}
}
}
| 17 |
8,145 | int main()
{
char a[10][20],b[10][20];
int i,t,y,u=0;
while(scanf("%s",a[u])!=EOF)
{
strcpy(b[u],a[u]);
for(t=0;a[u][t]!=0;t++)
{
if(a[u][t]!=40&&a[u][t]!=41)
b[u][t]=32;
if(b[u][t]==41)
{
for(y=t;y>-1;y--)
{
if(b[u][y]==40)
{b[u][y]=32;b[u][t]=32;break;}
}
}
}
for(t=0;b[u][t]!=0;t++)
{
if(b[u][t]==40)
b[u][t]=36;
else if(b[u][t]==41)
b[u][t]=63;
}
puts(a[u]);
puts(b[u]);
u++;
}
return 0;
}
| 17 |
8,146 |
int main(){
while(!cin.eof()){
char str[MAX],ans[MAX];
memset(str,0,sizeof(str));
memset(ans,0,sizeof(ans));
cin>>str;
for(int i=0;i<strlen(str);i++) ans[i]=' ';
int sign=0;
for(int i=0;i<strlen(str);i++){
if(str[i]=='('){
sign++;
ans[i]=sign+'0';
}
else if(str[i]==')'){
if(sign>0){
ans[i]=sign+'0';
sign--;
}
else ans[i]='?';
}
}
for(int i=0;i<strlen(str);i++){
if(ans[i]!=' '&&str[i]=='('){
int ok=0;
int j;
for(j=i+1;j<strlen(str);j++){
if(ans[j]==ans[i]){
ok=1;
break;
}
}
if(!ok) ans[i]='$';
else ans[i]=ans[j]=' ';
}
}
ans[strlen(str)]='\0';
cout<<str<<endl;
cout<<ans;
cout<<endl;
}
return 0;
}
| 17 |
8,147 | int main()
{
int n;
scanf("%d\n",&n);
char a[200];
int i;
for(i=0;i<n;i++)
{
scanf("%s",a);
printf("%s\n", a);
int j;
for(j=0;j<strlen(a);j++)
{
if(a[j]==')')
{
int s;
for(s=j-1;s>=0;s--)
{
if(a[s]=='(')
{
a[s]=' ';
a[j]=' ';
break;
}
}
}
}
for(j=0;j<strlen(a);j++)
{
if(a[j]==')')
printf("?");
else if(a[j]=='(')
printf("$");
else
printf(" ");
}
printf("\n");
}
return 0;
} | 17 |
8,148 | int k,m=0;
char a[100]={'\0'};
void pipei(int m,char a[])
{
int i,j;
for(i=m;i<=k-1;i++)
{
if(a[i]==')') {break;}
if(a[i]!='('&&a[i]!=')') {a[i]=' ';}
}
m=i+1;
for(j=i;j>=0;j--)
{
if(i==k&&a[k-1]!=')') break;
if(a[j]=='(') {a[j]=' ';a[i]=' ';break;}
}
if(m<=k-1) pipei(m,a);
}
int main()
{
char w;
while(cin>>a)
{
k=strlen(a);
int i,j;
cout<<a<<endl;
pipei(0,a);
for(i=0;i<=k-1;i++)
{
if(a[i]=='(')
a[i]='$';
if(a[i]==')')
a[i]='?';
}
for(i=0;i<=k-1;i++)
cout<<a[i];
cout<<endl;
for(i=0;i<100;i++)
{ a[i]='\0';}
}
return 0;
}
| 17 |
8,149 |
int main()
{ int i,j,t1,t2,flag,len;
int b[101],l[101],r[101];
char s[101];
while(scanf("%s",s)!=EOF){
len=strlen(s);
for(i=0;i<len;i++){
if(s[i]=='('){
b[i]=-1;
}
else if(s[i]==')'){
b[i]=1;
}
else{
b[i]=0;
}
}
t1=0;
t2=0;
for(i=0;i<len;i++){
if(b[i]==-1){
l[t1]=i;
t1++;
}
if(b[i]==1){
r[t2]=i;
t2++;
}
}
for(i=t1-1;i>=0;i--){
for(j=0;j<t2;j++){
if(r[j]>l[i]){
b[r[j]]=0;
b[l[i]]=0;
r[j]=0;
l[i]=0;
break;
}
}
}
puts(s);
for(i=0;i<len;i++){
if(b[i]==-1){
printf("$");
}
else if(b[i]==1){
printf("?");
}
else{
printf(" ");
}
}
printf("\n");
}
return 0;
}
| 17 |
8,150 | int main()
{
char kuohaoin[201]={0},kuohao1[201]={0},kuohaoout[201]={0};
int i,j,len;
while(cin>>kuohaoin)//??????
{
len=strlen(kuohaoin);//????
for(i=0;i<len;i++)
{
kuohao1[i]=kuohaoin[i];//????????????????
kuohaoout[i]=' ';
}
for(i=len-1;i>=0;i--)//????
{
if(kuohao1[i]=='(')//????
{
kuohaoout[i]='$';//??????????$
for(j=i+1;j<len;j++)//?????????)
{
if(kuohao1[j]==')')//???
{
kuohao1[j]='s';//?????????2???
kuohaoout[i]=' ';//?????????
kuohao1[i]='s';
break;
}
}
}
}
for(i=0;i<len;i++) if(kuohao1[i]==')')kuohaoout[i]='?';//??????????)
cout<<kuohaoin<<endl;
cout<<kuohaoout<<endl;
for(i=0;i<len;i++)//????
{
kuohaoin[i]=0;
kuohao1[i]=0;
kuohaoout[i]=0;
}
}
return 0;
} | 17 |
8,151 | int main()
{
char line[101];
int left[100]={0},right[100]={0}; //left?right???????????????
while(cin>>line)
{
int i,k1=0,k2=0;
for (i=0;i<strlen(line);i++)
{
if (line[i]=='(')
{
left[k1]=i;
k1++;
} //????????
if (line[i]==')')
{
if (k1!=0)
{
left[k1-1]=0;
k1--;
} //????????????????????
else
{
right[k2]=i;
k2++;
}
}
}
char ans[101];
for (i=0;i<strlen(line);i++)
ans[i]=' ';
ans[strlen(line)]='\0'; //?????????????????
for (i=0;i<k1;i++)
{
ans[left[i]]='$';
}
for (i=0;i<k2;i++)
{
ans[right[i]]='?';
} //??????????
cout <<line<<endl;
cout <<ans<<endl; //??
}
return 0;
} | 17 |
8,152 |
int main(){
int i,j,flag,q;
char str[101],note[101];
while(scanf("%s",str)!=EOF){
strcpy(note,str);
for(i=0;i<strlen(note);i++){
if((note[i]>='a'&¬e[i]<='z')||(note[i]>='A'&¬e[i]<='Z'))
note[i]=' ';
}
for(i=0;i<strlen(note);i++){
flag=0;
if(note[i]==')'){
for(j=i-1;j>=0;j--){
if(note[j]=='('){
flag=1;
note[j]=' ';
note[i]=' ';
break;
}
}
if(flag==0)
note[i]='?';
}
}
for(i=0;i<strlen(note);i++){
if(note[i]=='(')
note[i]='$';
}
puts(str);
puts(note);
}
scanf("%d",&q);
return 0;
}
| 17 |
8,153 | int main()
{
char a[101];
int i,t,j,la,k,bb,pp;
while(cin.getline(a,101,'\n'))
{
cout<<a<<endl;
la=strlen(a);
for(i=0;i<la;i++)
{
if(a[i]!='('&&a[i]!=')') a[i]=' ';
}
t=0;
while(t==0)
{
t=1;
for(i=la-1;i>=0;i--)
{
if(a[i]==')') break;
if(a[i]=='(')
{
a[i]='$';
break;
}
}
for(i=0;i<la;i++)
{
if(a[i]==')')
{
a[i]='?';
break;
}
if(a[i]=='(')
{
break;
}
}
for(i=0;i<la;i++)
{
if(a[i]=='(')
{
for(j=i+1;j<la;j++)
{
k=2;
if(a[j]=='(')
{
k=0;
break;
}
if(a[j]==')')
{
k=1;
a[j]=' ';
break;
}
}
if(k==1)
{
a[i]=' ';
}
}
}
for(i=0;i<la;i++)
{
if(a[i]=='('||a[i]==')')
{
t=0;
break;
}
}
}
for(i=la-1;i>=0;i--)
{
if(a[i]!=' ')
break;
}
bb=i;
for(i=0;i<la;i++)
{
if(a[i]!=' ') break;
}
pp=i;
for(j=pp;j<=bb;j++)
cout<<a[j];
cout<<endl;
}
return 0;
} | 17 |
8,154 | char c[120],ch;
int n;
int search(int p)//????????????????
{
int q=p+1;
if (q>=n) return q;
while ((c[q]!='?')&&(q<n))
{
if (c[q]=='$') q=search(q)+1;
else q++;
}
if (q<n)
{
c[p]=' ';
c[q]=' ';
}
return q;
}
int main()
{
int i=0;
while (cin>>ch)
{
cout<<ch;
n=0; i=0;
while (ch!='\n')
{
if (ch=='(') c[n]='$';
else
{if (ch==')') c[n]='?';
else c[n]=' ';}
n++;
cin.get(ch);
cout<<ch;
}
while (i<n)
{
while ((c[i]!='$')&&(i<n)) i++;
i=search(i)+1;
}
for (i=0; i<n; i++) cout<<c[i];
cout<<endl;
}
return 0;
} | 17 |
8,155 | int main(){
char s[160],ans[160];
int st[160],i,si;
for (;scanf("%s",s)!=EOF;){
for (ans[0]=' ',si=i=0;i<strlen(s);si-=(s[i]==')'&&si>0),ans[++i]=' ')
if (s[i]=='(') st[si++]=i;
else if (s[i]==')') ans[i]=(si>0)?' ':'?';
for (ans[strlen(s)]='\0',i=0;i<si;i++) ans[st[i]]='$';
printf("%s\n%s\n",s,ans);
}
} | 17 |
8,156 | int main()
{
void function(char a[200]);
char a[200];
while(scanf("%s",a)!=EOF)
{
function(a);
printf("%s\n",a);
}
return 0;
}
void function(char a[200])
{
int p[200];
int q[200];
int pa=0,qa=0,t1,t2,j,i,l;
pa=0;qa=0;
printf("%s\n",a);
l=strlen(a)-1;
for(i=0;i<=l;i++)
{
if(a[i]=='(')
{
p[pa]=i;
pa++;
}
else if(a[i]==')')
{
q[qa]=i;
qa++;
}
else a[i]=' ';
}
for(i=pa-1;i>=0;i--)
{
for(j=0;j<qa;j++)
{
t1=p[i];t2=q[j];
if(p[i]<q[j]&&a[t2]!=' ')
{
a[t1]=' ';a[t2]=' ';
break;
}
}
if(j==qa)
{
t1=p[i];
a[t1]='$';
}
}
for(j=0;j<qa;j++)
{
t2=q[j];
if(a[t2]==')')
a[t2]='?';
}
} | 17 |
8,157 |
int main()
{
char a[M][N],b[M][N];
int i,j,l,r;
int p,pi;
for(i=0;i<M;i++)
{
for(j=0;j<N;j++)
{
a[i][j]='\0';
b[i][j]='\0';
}
}
for(r=0;r<M;r++)
{
gets(a[r]);
strcpy(b[r],a[r]);
for(j=0;j<(strlen(a[r])+1)/2;j++)
{
for(i=0,pi=0,p=0;b[r][i]!='\0';i++)
{
if(b[r][i]=='(')
{
p=1;
pi=i;
}
if(b[r][i]==')'&&p==1)
{
b[r][i]='0';
b[r][pi]='0';
break;
}
}
}
//puts(b);
for(i=0;b[r][i]!='\0';i++)
{
if(b[r][i]=='(')
{
b[r][i]='$';
}
else if(b[r][i]==')')
{
b[r][i]='?';
}
else
b[r][i]=' ';
}
}
for(r=0;b[r][0]!='\0';r++)
{
puts(a[r]);
puts(b[r]);
}
return 0;
} | 17 |
8,158 | int i;
char x[101];
char y[101];
void f() {
int num = 0;
int k[101] = {0};
memset(y, ' ', 101);
int len = strlen(x);
for (i = 0; i < len; i++) {
if (x[i] == '(') {
y[i] = '$';
num = num + 1;//num?????????
k[num] = i;//?????????
}
if (x[i] == ')') {
if (num > 0) {
y[k[num]] = ' ';
num = num - 1;//?????????
} else
y[i] = '?';
}
}
for (i = 0; i < len; i++) {
cout << y[i];//??
}
cout << endl;
}
int main() {
while(cin >> x){
cout << x << endl;
f();
}
return 0;
}
| 17 |
8,159 | int main()
{
int n;
char a[1000],b[1000];
int i, j, k, e=0;
scanf("%d", &n);
for(i=1;i<n+1;i++)
{
scanf("%s", &a);
for(j=0;j<strlen(a);j++)
{
if(a[j]!='(' && a[j]!=')')
{
b[j]=' ';
}
else
{
b[j]=a[j];
}
}
//??????????????
for(j=0;j<strlen(a);j++)
{
if(b[j]=='(')
{
for(k=j+1;k<strlen(a);k++)
{
if(b[k]=='(')
{
e++;
}
else if(b[k]==')' && e==0 )
{
b[k]=' ';
b[j]=' ';
e++;
}
}
e=0;
}
//?????????????????????
else if(b[j]==')')
{
e=0;
k=j-1;
for(k=j-1;k>0;k--)
{
if(b[k]=='(')
{
b[k]=' ';
b[j]=' ';
k=0;
e=1;
}
}
if(e==0 && b[0]=='(')
{
b[0]=' ';
b[j]=' ';
}
}
}
//????????????????????????
for(j=0;j<strlen(a);j++)
{
if(b[j]=='(')
{
b[j]='$';
}
else if(b[j]==')')
{
b[j]='?';
}
}
//???????????????$??
for(j=0;j<strlen(a);j++)
{
printf("%c", a[j]);
}
printf("\n");
for(j=0;j<strlen(a);j++)
{
printf("%c", b[j]);
}
printf("\n");
}
return 0;
}
| 17 |
8,160 | void f(int n,char b[])
{
if(n>0)
f(n-1,b);
int i=0,k=0,x=0;
for(k=0;k<n;k++)
{
if(b[k]==')')
{
for(x=0;x<=k;x++)
{
if(b[k-x]=='(')
{
b[k]=' ';
b[k-x]=' ';
break;
}
}
}
}
}
int main()
{
int j=0;
for(j=0;j<10;j++)
{
char a[200]={0},b[200]={0};
int i=0,k=0,x=0,n=0;
for(i=0;;i++)
{
a[i]=getchar();
b[i]=a[i];
if(b[i]!='('&&b[i]!=')'&&b[i]!='\n')
b[i]=' ';
if(a[i]=='\n')
break;
n++;
}
f(n,b);
for(i=0;i<n;i++)
cout<<a[i];
cout<<endl;
for(i=0;i<n;i++)
{
if(b[i]=='(')
b[i]='$';
else if(b[i]==')')
b[i]='?';
}
for(i=0;i<n;i++)
cout<<b[i];
cout<<endl;
}
return 0;
}
| 17 |
8,161 | int main()
{
int n,i;
scanf("%d",&n);
char a[1000],b[1000];
int j,l,r;
for(i=0;i<n;i++)
{
memset(a,'\n',200);
memset(b,'\n',200);
scanf("%s",a);
printf("%s\n",a);
l=strlen(a);
for(j=0;j<l;j++)
{
if(a[j]=='(')
{
b[j]='$';
}
else if(a[j]==')')
{
b[j]='?';
for(r=j-1;r>=0;r--)
{
if(b[r]=='$')
{
b[r]=' ';
b[j]=' ';
break;
}
}
}
else if(a[j]!='(' && a[j]!=')')
{
b[j]=' ';
}
}
printf("%s\n",b);
}
return 0;
}
| 17 |
8,162 |
char c[101], a[101] = { ' ' };
int leftpos[101] = { 0 }, leftnum = 0;
void function(int pos)
{
if (pos == strlen(c))
{
a[pos] = '\0';
cout << c << endl;
cout << a << endl;
return;
}
if (c[pos] == '(')
{
leftpos[leftnum] = pos;
a[pos] = '$';
leftnum += 1;
function(pos + 1);
}
else
{
if (c[pos] == ')')
{
if (leftnum == 0)
{
a[pos] = '?';
function(pos + 1);
}
else
{
a[pos] = ' ';
leftnum -= 1;
a[leftpos[leftnum]] = ' ';
function(pos + 1);
}
}
else
{
a[pos] = ' ';
function(pos + 1);
}
}
}
int main()
{
for (; cin.getline(c, 101);)
{
function(0);
leftnum = 0;
for (int i = 0; i < 101; i++)
leftpos[i] = 0;
}
return 0;
}
| 17 |
8,163 |
void match(char *p)
{
int n=(int )strlen(p);
int a[100]={0};
int i,j;
for(i=j=0;i<n;i++)
{
if(p[i]==')')
{
for(j=i;j>=0;j--)
if(p[j]=='(')
{
p[j]=p[i]='a';
break;
}
}
}
for(i=0;i<n;i++)
if(p[i]=='(')printf("$");
else if(p[i]==')') printf("?");
else printf(" ");
printf("\n");
}
void main()
{
int i=0,n;
scanf("%d",&n);
while(i<n)
{
char s[103]={'\0'};
scanf("%s",s);
printf("%s\n",s);
match(s);
i++;
}
} | 17 |
8,164 | int main()
{
char line[101], label[101];
int pos[100];
int left = 0, right = 0;
int pos_i, length;
int i;
while(cin.getline(line, sizeof(line)))
{
for(i = 0; i < 101; i++)
label[i] = ' ';
pos_i = -1, left = 0, right = 0;
length = strlen(line);
for(i = 0; line[i] != '\0'; i++)
{
if(line[i] == '(')
{
pos_i++;
pos[pos_i] = i;
left++;
}
if(line[i] == ')')
{
if(right >= left)
label[i] = '?';
else
{
right++;
pos_i--;
}
}
}
if(pos_i >= 0)
{
for(i = 0; i <= pos_i; i++)
label[pos[i]] = '$';
}
label[length] = '\0';
cout << line << endl;
cout << label << endl;
}
return 0;
}
| 17 |
8,165 | int main()
{
char line[101],label[101];
int pos[101];
int n , j ;
int left;
cin >> n ;
cin.get();
for( j = 1 ;j <= n ;j ++ )
{
left = 0 ;
cin .getline(line,101);
int len = strlen(line);
for(int i = 0 ;i <= 100 ; i ++ )
label[i]=' ';
for( int i = 0 ;i <= len - 1; i ++ )
{
if(line[i] == '(')
{
left ++ ;
pos[left] = i ;
}
if(line[i] == ')')
{
if( left == 0)
label[i] ='?';
else
left -- ;
}
}
for( int i = 1 ;i <= left ; i ++ )
label[pos[i]]='$';
label[len]='\0';
cout<< line << endl ;
cout<< label << endl ;
}return 0 ;
}
| 17 |
8,166 | int main()
{
while(1)
{
char s[101], zhui = '#';
int count[101] = {0};//count = 1????count = 2???
int i = 0, j = 0, sl = 0, p = 0, q = 0;
for (i = 0; i < 101; i ++)
{s[i] = '#';}//???
//??
cin.getline(s, 101);
sl = strlen(s);
if(s[0] == '\0'){break;}//???????????
//???
for (i = 0; i < sl; i ++)
{
if(s[i] == '(')
{
count[i] = 1;
}
else if(s[i] == ')')
{
count[i] = 2;
}
else{continue;}
}
//??????????0
for (i = sl - 1; i >= 0; i --)
{
if(count[i] == 1)
{
for (j = i + 1; j < sl; j ++)
{
if(count[j] == 2)
{
count[i] = 0;
count[j] = 0;
break;
}
}
}
}
//???0?????????;
int dingzuo[101] = {0};
int dingyou[101] = {0};
int flag = 0;//???????
int count0 = 0;
for (i = 0; i < sl; i ++)
{
if(count[i] == 1)
{
dingzuo[i] = 1;
flag = 1;
count0 ++;
}
else if(count[i] == 2)
{
dingyou[i] = 1;
flag = 1;
count0 ++;
}
else
{continue;}
}
//??
int k = count0;
for (i = 0; i < sl; i ++)
{cout << s[i];}//???????
if(flag == 1)
{
cout << endl;
for (i = 0; i < sl; i ++)
{
if(dingzuo[i] == 1)
{
cout << "$";
count0 --;
}
else if(dingyou[i] == 1)
{
cout << "?";
count0 --;
}
else
{
if((count0 > 0) && (count0 < k))
{cout << " ";}
}
}
cout << endl;
}
else
{cout << endl;}
}
return 0;
}
| 17 |
8,167 | /**
??????
*/
int main()
{
char str[101], flag[101];
while( cin.getline(str, 101))
{
cout << str << endl;
int len, num = 0;
len = strlen(str);
int i, j;
for ( i = 0; i < len; i ++ )
flag[i] = ' ';
flag[i] = '\0';
for ( i = 0; i < len; i ++ )
{
if ( str[i] == '(')
{
num ++;
flag[i] = '$';
}
if ( str[i] == ')')
{
num --;
if ( num >= 0 )
{
for ( j = i - 1; j >= 0; j -- )
if ( str[j] =='(' )
{
flag[j] = ' ';
str[j] = ' ';
break;
}
}
else
{
flag[i] = '?';
num ++;
}
}
}
cout << flag << endl;
}
return 0;
} | 17 |
8,168 | int main()
{
char z[101];
int i,j,l[101],r[101];
while(scanf("%s",z)!=EOF)
{
for(i=0;i<101;i++)
{
l[i]=0;
r[i]=0;
}
for(i=0;i<strlen(z);i++)
{
if(z[i]=='(')
l[i]=1;
if(z[i]==')')
r[i]=1;
}
for(i=0;i<strlen(z);i++)
{
if(l[i]==1)
{
for(j=i+1;j<strlen(z);j++)
{
if(l[j]==1)
l[i]++;
if(r[j]==1)
l[i]--;
if(l[i]==0)
{
r[j]=0;
break;
}
}
}
}
printf("%s\n",z);
for(i=0;i<strlen(z);i++)
{
if(l[i]!=0)
printf("$");
else if(r[i]!=0)
printf("?");
else
printf(" ");
}
printf("\n");
}
return 0;
} | 17 |
8,169 | int deal();
char ori[101]={"\0"};
int out[101]={0};
int main()
{
int i;
while(cin.getline(ori,101))
{
deal();
cout<<ori<<endl;
for (i=0;ori[i]!='\0';i++)
{
if (out[i]==1)
cout<<'$';
else if (out[i]==2)
cout<<'?';
else
cout<<' ';
}
cout<<endl;
}
return 0;
}
int deal()
{
int i,j;
for (i=0;ori[i]!='\0';i++)
{
if (ori[i]=='(')
out[i]=1;
else if (ori[i]==')')
out[i]=2;
else
out[i]=0;
}
for (i=0;ori[i]!='\0';i++)
{
if (out[i]==2)
{
for (j=i;j>=0;j--)
{
if (out[j]==1)
{
out[i]=0;
out[j]=0;
break;
}
}
}
}
return 0;
}
| 17 |
8,170 | void Find( char * );
int main()
{
int i;
char str[ 101 ];
char mark[ 101 ];
while ( cin.getline( str, 101 ) )
{
memset( mark, 0, sizeof( mark ) );
for ( i = 0; i < strlen( str ); i++ )
{
if ( str[ i ] == '(' )
{
mark[ i ] = '$';
}
if ( str[ i ] == ')' )
{
mark[ i ] = '?';
}
if ( str[ i ] != '(' && str[ i ] != ')' )
{
mark[ i ] = ' ';
}
}
Find( mark );
for ( i = strlen( mark ) - 1; i >= 0; i-- )
if ( mark[ i ] != ' ' )
{
mark[ i + 1 ] = 0;
break;
}
for ( i = 0; i < strlen( mark ); i++ )
if ( mark[ i ] != ' ' )
{
strcpy( mark, mark + i );
break;
}
cout << str << endl << mark << endl;
}
}
void Find( char mark[] )
{
int i, j = 0;
for ( i = 0; i < strlen( mark ); i++ )
{
if ( mark[ i ] == '$' )
{
for ( j = i + 1; j < strlen( mark ); j++ )
{
if ( mark[ j ] == '$' )
{
break;
}
else
{
if ( mark[ j ] == '?' )
{
mark[ j ] = ' ';
mark[ i ] = ' ';
Find( mark );
return;
}
}
}
}
}
}
| 17 |
8,171 | char investigate(char a[])
{
int i,j,k,n;
int p1=0,p2=0,w,t=0,t1=0;
n=strlen(a);
char b[100];
for(i=0;i<n;i++)
{
if(a[i]=='(') p1++;
if(a[i]==')') p2++;
}
for(i=0;i<n;i++)
{
if((i==(n-1))&&(t>t1))
{
i=-1;t1=t;goto loop;
}else
if(a[i]!='('){b[i]==' ';continue;}
else
{
for(j=i+1;j<n;j++)
{
if(a[j]=='('){i=j-1;break;}
else if(a[j]==')')
{
a[i]='[';a[j]=']';t++;
break;
}
}
}
loop:;
}
for(i=0;i<n;i++)
{
if(a[i]=='(') b[i]='$';
else if(a[i]==')') b[i]='?';
else b[i]=' ';
}
for(i=0;i<n;i++)
{
if(a[i]=='[')a[i]='(';
if(a[i]==']')a[i]=')';
}
for(i=0;i<n;i++)
printf("%c",a[i]);
printf("\n");
for(i=0;i<n;i++)
printf("%c",b[i]);
return 0;
}
int main()
{
int i,j;
char a[100];
while(gets(a))
{
investigate(a);
printf("\n");
}
}
| 17 |
8,172 | int main(){
int ghus(char a[]);
void noghus(char a[]);
int n,i,t,j;
char b[500];
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%s",b);
t=ghus(b);
printf("%s\n",b);
for(j=1;j<=t;j++){
noghus(b);
}
for(j=0;j<strlen(b);j++){
if(b[j]=='(') printf("$");
else if(b[j]==')') printf("?");
else printf(" ");
}
printf("\n");
}
}
int min(int a,int b){
if(a<b) return a;
else return b;
}
int ghus(char a[]){
int min(int a,int b);
int m=0,n=0,i;
for(i=0;i<strlen(a);i++){
if(a[i]=='(') m++;
if(a[i]==')') n++;
}
return min(m,n);
}
void noghus(char a[]){
int i,j;
for(i=0;i<strlen(a)-1;i++){
if(a[i]=='('){
for(j=i+1;j<strlen(a);j++){
if(a[j]==')'||a[j]=='(') break;
}
if(a[j]==')'){
a[i]='o';
a[j]='o';
}
}
}
}
| 17 |
8,173 | void find(char a[],int n,int m)
{
int i;
if(a[m]!=')'&&m<n)
{find(a,n,m+1);}//??????????
if(a[m]==')'&&m<n)
{
for(i=m;i>=0;i--)
{
if(a[i]=='(')
{a[i]=' ';a[m]=' ';break;}//????????
}
find(a,n,m+1);//????
}
}
int main()
{
int n;
char a[200];
while(cin>>a)//??
{
cout<<a<<endl;//??????
n=strlen(a);
find(a,n,0);//????????
for(int k=0;k<n;k++)
{
if(a[k]=='(')
{a[k]='$';}//???????
else
{if(a[k]==')')//???????
{a[k]='?';}
else
{if(a[k]!='('&&a[k]!=')')//?????????
{a[k]=' ';}
}
}
}
cout<<a<<endl;//???????
}
return 0;
} | 17 |
8,174 |
int main()
{
for (char c[101]; cin.getline(c, 101);)
{
char a[101] = { ' ' };
int len = strlen(c), cnt = 0, left[101] = { 0 };
for (int i = 0; i < len; i++)
{
if (c[i] != '(' && c[i] != ')')
a[i] = ' ';
else
{
if (c[i] == '(')
{
a[i] = '$';
cnt += 1;
left[cnt] = i + 1;
}
else
{
if (cnt<=0)
a[i] = '?';
else
{
a[i] = ' ';
a[left[cnt]-1] = ' ';
left[cnt] = 0;
cnt -= 1;
}
}
}
}
cout << c << endl;
cout << a << endl;
}
return 0;
}
| 17 |
8,175 | int main()
{
char str[101]={"0"};
int i,j,len,zuo,you,a[100];
while(scanf("%s",str)!=EOF){
len=strlen(str);
for(i=0;i<len;i++)
a[i]=0;
for(i=len-1;i>=0;i--){
if(str[i]=='('){
zuo=0;you=0;
for(j=i+1;j<len;j++){
if(str[j]=='('&&a[j]!=1)
zuo++;
else if(str[j]==')')
you++;
}
if(you<zuo+1)
a[i]=1;
}
}
for(i=0;i<len;i++){
if(str[i]==')'){
zuo=0;you=0;
for(j=0;j<i;j++){
if(str[j]=='(')
zuo++;
else if(str[j]==')'&&a[j]!=-1)
you++;
}
if(zuo<you+1)
a[i]=-1;
}
}
printf("%s\n",str);
for(i=0;i<len;i++){
if(a[i]==0) printf(" ");
else if(a[i]==1) printf("$");
else printf("?");
}
printf("\n");
}
return 0;
}
| 17 |
8,176 | int main()
{
int n;
for(scanf("%d%*c",&n);n>0;n--)
{
char a[101];
gets(a);
puts(a);
int i,j,k,l=strlen(a);
do
{
for(j=0;j<l;j++)
if(a[j]==')')break;
if(j!=l)
{
for(k=j;k>=0;k--)
if(a[k]=='(')break;
if(k<0)a[j]='?';
else a[j]=a[k]=' ';
}
}while(j!=l);
for(i=0;i<l;i++)
if(a[i]=='(')a[i]='$';
else if(a[i]!='?')a[i]=' ';
puts(a);
}
return 0;
}
| 17 |
8,177 | int main()
{
int i=0,j=0,m=0,n=0,k=0;
char s[105];
while(cin.getline(s,105,'\n'))
{
int zuo[100],you[100],flag[105]={0};
char a[105];
for(i=0;s[i]!='\0';i++)
{
a[i]=' ';
}
a[i]='\0';
m=0;
n=0;
for(j=0;j<i;j++)
{
if(s[j]=='(')
zuo[m++]=j;
if(s[j]==')')
you[n++]=j;
}
for(j=0;j<n;j++)
{
for(k=you[j]-1;k>=0;k--)
{
if(s[k]=='('&&flag[k]==0)
{
flag[k]=1;
flag[you[j]]=1;
break;
}
}
}
for(k=0;k<i;k++)
{
if(flag[k]==0&&s[k]=='(')
a[k]='$';
if(flag[k]==0&&s[k]==')')
a[k]='?';
}
cout<<s<<endl;
cout<<a<<endl;
}
return 0;
} | 17 |
8,178 | int main()
{
char c[101];
int i,a[101],j=0,k;
while(scanf("%s", c) != EOF)
{
puts(c);
for(i=0;;i++)
{
if(c[i]=='\0')break;
else
{
if(c[i]=='(')
{
j++;a[j]=i;
}
else if(c[i]==')')
{
if(j>0)
{
c[i]=' ';
c[a[j]]=' ';
j--;
}
}
}
}
for(k=0;k<i;k++)
{
if (c[k]=='(')printf("$");
else if(c[k]==')')printf("?");
else printf(" ");
}
j=0;
printf("\n");
}
}
| 17 |
8,179 | int main()
{
int i,j,t,n1,n2;
int k[100];
char a[100][100],b[100];
i=0;
while(gets(a[i]))
{
k[i]=strlen(a[i]);//??????????
if(k[i]==0)
break;
i++;
}//????????????????
t=i;
for(i=0;i<t;i++)
{
n1=0;
n2=0;
for(j=0;j<k[i];j++)
{
b[j]=' ';
}//???b??????
for(j=0;j<k[i];j++)//????
{
if(n1<0)
n1=0;//?n1???0
if(a[i][j]=='(')
{
n1++;
}//???????n1?1
if(a[i][j]==')')
{
if(n1==0)
{
b[j]='?';
}
n1--;
}//???????n1?1????1?n1?0??b?j?=?
}
for(j=k[i]-1;j>=0;j--)//????
{
if(n2<0)
n2=0;//?n2???0
if(a[i][j]==')')
{
n2++;
}//???????n2?1
if(a[i][j]=='(')
{
if(n2==0)
{
b[j]='$';
}
n2--;
}//???????n2?1????1?n2?0??b?j?=$
}
for(j=0;j<k[i];j++)
{
cout<<a[i][j];
}
cout<<endl;//????????
for(j=0;j<k[i];j++)
{
cout<<b[j];
}
cout<<endl;//????b???
}
return 0;
}
| 17 |
8,180 | /*
* match (.cpp
*??:????????
* Created on: 2012-12-1
* Author: ???
*/
char sign[101]; //????,??
int lf[100]; //????lf,??(???
int rt[100]; //????rt,??)???
int len; //??????
void match(); //????
int main ()
{
while(cin.getline(sign,101))
{
len=strlen(sign); //???
cout<<sign<<endl; //??????
int i=0;
for(i=0;i<100;i++) //???
{
lf[i]=-1;
rt[i]=-1;
}
match(); //????match
}
return 0;
}
void match()
{
int i=0,j=0,n1=0,n2=0; //(,)???
char result[len];
for(i=0;i<len;i++)
result[i]=' '; //???
for(i=0;i<len;i++) //??(,)???
{
if(sign[i]=='(')
{
lf[n1]=i;
n1++;
}
if(sign[i]==')')
{
rt[n2]=i;
n2++;
}
}
for(i=n1-1;i>=0;i--) //??????
for(j=0;j<n2;j++)
if(lf[i]<rt[j])
{
lf[i]=-1;
rt[j]=-1;
break;
}
for(i=0;i<n1;i++) //?????
if(lf[i]>=0)
result[lf[i]]='$';
for(j=0;j<n2;j++)
if(rt[j]>=0)
result[rt[j]]='?';
for(i=0;i<len;i++) //??
cout<<result[i];
cout<<endl;
} | 17 |
8,181 | int main()
{
void kuo(char c[]);
void pipei(char c[],char a[]);
int n,i;
scanf("%d\n",&n);
for(i=0;i<n;i++)
{
char c[200]={'\0'},a[200]={'\0'};
gets(c);
printf("%s\n",c);
kuo(c);
pipei(c,a);
}
return 0;
}
void pipei(char c[],char a[])
{
char *p,*q;
for(p=c,q=a;*p!='\0';p++,q++)
{
if(*p!='('&&*p!=')')
*q=' ';
if(*p==')')
*q='?';
if(*p=='(')
*q='$';
}
*q=*p;
printf("%s\n",a);
}
void kuo(char c[])
{
char *p,*q,*i,*t;
int s;
for(;;)
{
s=0;
for(i=c;*i!='\0';i++)
for(p=i;*p!='\0';p++)
{
if(*p=='(')
for(q=p+1;*q!='\0';q++)
{
if(*q=='(')
break;
else
if(*q==')')
{
*p='a';
*q='a';
break;
}
}
}
for(q=c;*q!='\0';q++)
{
for(t=q;*t!='\0';t++)
{
if(*q=='('&&*t==')')
s=1;
}
}
if(s==0)
break;
}
} | 17 |
8,182 | main()
{
char a[100][101],b[101],c[101];
int n,m;
scanf("%d",&n);
for(m=0;m<n;m++)
{
scanf("%s",a[m]);
}
for(m=0;m<n;m++)
{int i=0,j=0,k=0;int n;
n=strlen(a[m]);
for(i=0;i<n;i++)
{b[i]=' ';
c[i]=' ';}
for(i=n-1;i>=0;i--)
if(a[m][i]=='(')
b[i]=a[m][i];
for(i=0;i<n;i++)
if(a[m][i]==')')
c[i]=a[m][i];
for(i=n-1;i>=0;i--)
if(b[i]=='(')
{for(j=i+1;j<n;j++)
if(c[j]==')')
{c[j]=' ';
b[i]=' ';
break;}}
printf("%s\n",a[m]);
for(i=0;i<n;i++)
{if(b[i]!=' ')
a[m][i]='$';
if(c[i]!=' ')
a[m][i]='?';
if(b[i]==' '&&c[i]==' ')
a[m][i]=' ';
}
printf("%s\n",a[m]);
}
}
| 17 |
8,183 |
right(char s[],int i,int n)
{
int j;
int left=0,right=0;
int num=0;
for(j=i+1;j<n;j++){
if(s[j]=='(') right++;
if(s[j]==')') left++;
if(right<left) {num=1;break;}
}
return(num);
}
left(char s[],int i)
{
int j;
int left=0,right=0;
int num=0;
for(j=i-1;j>=0;j--){
if(s[j]=='(') right++;
if(s[j]==')') left++;
if(right>left) {num=1;break;}
}
return(num);
}
trans(char s1[],char s2[])
{
int len;
int i;
len=strlen(s1);
for(i=0;i<len;i++){
if(s1[i]!=')'&&s1[i]!='(')
s2[i]=' ';
if(s1[i]==')')
{
if(left(s1,i)==1) s2[i]=' ';
else s2[i]='?';
}
if(s1[i]=='(')
{
if(right(s1,i,len)==1) s2[i]=' ';
else s2[i]='$';
}
}
s2[len]='\0';
return;
}
main()
{
int i,j;
int n;
struct aaa
{
char s1[105];
char s2[105];
};
struct aaa line[20];
scanf("%d\n",&n);
for(i=0;i<n;i++){
gets(line[i].s1);
trans(line[i].s1,line[i].s2);
}
for(i=0;i<n;i++)
printf("%s\n%s\n",line[i].s1,line[i].s2);
} | 17 |
8,184 | int main()
{
int j=0;
for(j=0;j<10;j++)
{
char a[200]={0},b[200]={0};//a??????b???????
int i=0,k=0,x=0,n=0;//??,n?????
for(i=0;;i++)//?????????
{
a[i]=getchar();
if(a[i]=='\n')
break;
n++;
}
for(i=0;i<n;i++)//?????b
b[i]=a[i];
for(i=0;i<n;i++)//?????????
if(b[i]!='('&&b[i]!=')')
b[i]=' ';
for(i=0;i<n;i++)//????????,???????????,??,??????????
{
for(k=0;k<n;k++)
{
if(b[k]==')')
{
for(x=0;x<=k;x++)
{
if(b[k-x]=='(')
{
b[k]=' ';
b[k-x]=' ';
break;
}
}
}
}
}
for(i=0;i<n;i++)//??????????
{
if(b[i]=='(')
b[i]='$';
else if(b[i]==')')
b[i]='?';
}
for(i=0;i<n;i++)//??
cout<<a[i];
cout<<endl;
for(i=0;i<n;i++)
cout<<b[i];
cout<<endl;
}
return 0;
}
| 17 |
8,185 | int main()
{
int n;
scanf("%d",&n);
int i;
for(i=0;i<n;i++)
{
int j;
int a[1000];
char s[1000];
scanf("%s",s);
int l=strlen(s);
printf("%s\n",s);
for(j=0;j<l;j++)
a[j]=0;
for(j=l-1;j>=0;j--)
{
int t;
if(s[j]=='(')
{
int f=0;
for(t=j+1;t<l;t++)
{
if(s[t]==')'&&a[t]==0)
{f=1;a[t]=1;a[j]=1;break;}
}
if(f==0)
{
s[j]='$';
}
}
}
for(j=0;j<l;j++)
{
if(s[j]==')'&&a[j]==0)
{
s[j]='?';
}
}
for(j=0;j<l;j++)
{
if(s[j]!='?'&&s[j]!='$')
s[j]=' ';
}
printf("%s\n",s);
}
} | 17 |
8,186 | int main()
{
int n;
char b[1000],bc[1000];
scanf("%d",&n);
int a;
getchar();
for(a=0;a<n;a++)
{
gets(b);
int c;
c=strlen(b);
int ch;
for(ch=0;ch<c;ch++)
printf("%c",b[ch]);
int d;
for(d=0;d<c;d++)
{
if(b[d]=='(')
{
int e;
int shao[100],f=0;
shao[0]=d;
for(e=d+1;e<c;e++)
{
if(b[e]=='(')
{
f++;
shao[f]=e;
}
else if(b[e]==')')
{
b[e]=' ';
b[shao[f]]=' ';
f--;
}
if(f==-1)
break;
}
if(f!=-1)
b[d]='$';
}
else if(b[d]==')')
{
b[d]='?';
}
else
b[d]=' ';
}
printf("\n");
int x;
for(x=0;x<c;x++)
printf("%c",b[x]);
printf("\n");
}
return 0;
}
| 17 |
8,187 | /*
* ????match.cpp
* ???? : 2012-12-4
* ??: winneshaw
* ??????????????????
* ??????????????????????????????????
* ???????????"$"??,?????????"?"??
*
*/
char str[101];
int lenth = 0;
int main() {
while(cin >> str){
lenth = strlen(str);
cout << str << endl;
int i, j;
for (j = 0; j < lenth; j++) {
if (str[j] == '(')
str[j] = '$';
else if (str[j] == ')')
str[j] = '?';
else
str[j] = ' ';
}
for (i = lenth - 2; i >= 0; i--) {
if (str[i] == '$') {
for (j = i + 1; j < lenth; j++) {
if (str[j] == '?') {
str[i] = ' ';
str[j] = ' ';
break;
}
}
}
}/*
if (str[lenth - 1] == '?')
for (i = 0; i < lenth; i++)
if (str[i] == '$') {
str[lenth - 1] = ' ';
str[i] = ' ';
break;
}*/
cout << str << endl;
}
return 0;
}
| 17 |
8,188 | int main(){
char zf[106];
while(1) {
memset(zf,'\0',sizeof (zf));
gets(zf);
if (zf[0]=='\0')
break;
puts(zf);
for (int i=0;i<strlen(zf);i++){
if(zf[i]==')'){
for (int j=i;j>=0;j--){
if (zf[j]=='('){
zf[j]=' ';
zf[i]=' ';
break;
}
}
}
else if (zf[i]!='(') {
zf[i]=' ';
}
}
for (int t=0;t<strlen(zf);t++){
if(zf[t]=='('){
zf[t]='$';
}
else if (zf[t]==')'){
zf[t]='?';
}
}
puts(zf);
}
return 0;
} | 17 |
8,189 | int main()
{
char str[101];
int i , j , a[101] , len , count;
while (cin.getline(str , 101))
{
count = 0;
len = strlen(str);
for (i = 0 ; i <= len -1 ; i++)
{
cout << str[i];
}
cout << endl;
for (i = 0 ; i <= len - 1 ; i++)
{
if (str[i] == ')')
{
count++;
a[count] = i;
}
}
for (i = 1 ; i <= count ; i++)
{
for (j = a[i] - 1 ; j >= 0 ; j--)
{
if (a[i] == 0)
{
str[a[i]] = '?';
}
if (str[j] == '(')
{
str[j] = ' ';
str[a[i]] = ' ';
break;
}
}
if (str[a[i]] != ' ')
{
str[a[i]] = '?';
}
}
for (i = 0 ; i <= len -1 ; i++)
{
if (str[i] == '(')
{
str[i] = '$';
}
}
for (i = 0 ; i <= len -1 ; i++)
{
if ((str[i] != ' ')&&(str[i] != '?')&&(str[i] != '$'))
{
str[i] = ' ';
}
}
for (i = 0 ; i <= len -1 ; i++)
{
cout << str[i];
}
cout << endl;
}
return 0;
} | 17 |
8,190 | main()
{
int n,i,j,k,count,mz;
char a[200]={'\0'},b[200];
scanf("%d\n",&n);
for(i=0;i<n;i++)
{
count=0;
for(j=0;j<200;j++)
{
a[j]='\0';
b[j]='\0';
}
gets(a);
strcpy(b,a);
for(j=0;j<200;j++)
{
if(a[j]=='\0')break;
count++;
}
for(j=count-1;j>=0;j--)
{
if(b[j]=='(')
{
mz=0;
for(k=j;k<count;k++)
{
if(b[k]==')')
{
b[k]=' ';
b[j]=' ';
mz=1;break;
}
}
if(mz==0)b[j]='$';
}
}
for(j=0;j<count;j++)
{
if(b[j]==')')b[j]='?';
}
for(j=0;j<count;j++)printf("%c",a[j]);
printf("\n");
for(j=0;j<count;j++)
{
if(b[j]!='$' && b[j]!='?')printf(" ");
else printf("%c",b[j]);
}
printf("\n");
}
} | 17 |
8,191 | char word[200];
int pp[200],len;
void op()
{
int t=0,i;
for(i=0;i<=len;i++)
pp[i]=0;
for(i=0;i<len;i++)
{
if(word[i]=='(')
t++;
if(word[i]==')')
{
t--;
if(t<0)
{pp[i]=ykhao;
t++;}
}
}
t=0;
for(i=len-1;i>=0;i--)
{
if(word[i]==')'&&pp[i]!=ykhao)
t++;
if(word[i]=='(')
{
t--;
if(t<0)
{pp[i]=zkhao;
t++;}
}
}
}
void pr()
{
int i;
printf("%s\n",word);
for(i=0;i<len;i++)
{
if(pp[i]==0)
printf(" ");
if(pp[i]==zkhao)
printf("$");
if(pp[i]==ykhao)
printf("?");
}
}
/*int main()
{
printf("1");
getch();
return 0;
}*/
int main()
{
int n,i;
//freopen("1.txt","w",stdout);
scanf("%d\n",&n);
gets(word);
len=strlen(word);
op();
pr();
for(i=2;i<=n;i++)
{gets(word);
len=strlen(word);
printf("\n");
op();
pr();
}
//getch();
return 0;
}
| 17 |
8,192 | int main()
{
int n,i,j;
char a[101];
while(gets(a))
{
n=strlen(a);
for(i=0;i<=n-2;i++)
{
printf("%c",a[i]);
}
printf("%c\n",a[n-1]);
for(i=0;i<n;i++)
{
if(a[i]==')')
{
for(j=i;j>=0;j--)
{
if(a[j]=='(')
{
a[j]=' ';
a[i]=' ';
break;
}
}
}
}
for(i=0;i<n;i++)
{
if(a[i]>='a'&&a[i]<='z'||a[i]>='A'&&a[i]<='Z'||a[i]==' ')
{
a[i]=' ';
}
else if(a[i]==')')
{
a[i]='?';
}
else if(a[i]=='(')
{
a[i]='$';
}
}
for(i=0;i<n;i++)
{
printf("%c",a[i]);
}
printf("\n");
}
}
| 17 |
8,193 | int main() {
char jiance[101], c;
int i, zifu, kuo2[100];
while (cin >> jiance) {//???????
cout << jiance << endl;//????????
zifu = -1;
for (i = 0; jiance[i] != 0; i++) {
c = jiance[i];
jiance[i] = ' ';//???????
if (c == '(') {//??????
zifu++;
kuo2[zifu] = i;
} else if (c == ')') {//?????
zifu--;
if (zifu < -1) {
jiance[i] = '?';//???????????
zifu = -1;
}
}
}
if (zifu > -1)
for (; zifu > -1; zifu--)
jiance[kuo2[zifu]] = '$';//????????????
cout << jiance << endl;
}
return 0;
}
| 17 |
8,194 | int main()
{
char str[1001];int n;
while(~scanf("%s",str))
{
n=strlen(str);
printf("%s",str);
printf("\n");
for(int i=1;i<n;i++)
{
if(str[i]==')')
{
for(int j=i-1;j>=0;j--)
{if(str[j]=='(') {str[i]=' ';str[j]=' ';break;}}
}
}
for(int i=0;i<n;i++)
{
if(str[i]=='(') str[i]='$';
else if(str[i]==')') str[i]='?';
else str[i]=' ';
}
printf("%s",str);
printf("\n");
}
} | 17 |
8,195 | char s[105];
int len;
int f(int b) {
for (int i = b + 1; i < len; i++) {
if (s[i] == ')') {
s[b] = '$';
s[i] = '?';
return i;
} else if (s[i] == '(') {
i = f(i);
}
}
return len - 1;
}
int main() {
while (cin >> s) {
len = strlen(s);
cout << s << endl;
for (int i = 0; i < len; i++) {
if (s[i] == '(')
i = f(i);
}
for (int i = 0; i < len; i++) {
if (s[i] == '(')
cout << '$';
else if (s[i] == ')')
cout << '?';
else
cout << ' ';
}
cout << endl;
}
return 0;
}
| 17 |
8,196 | void main()
{
int n,i,j,k,m;
scanf("%d",&n);
getchar();
for(i=0;i<n;i++)
{
char a[200]={0};
char b[200]={0};
gets(a);
k=strlen(a);
for(j=0;j<k;j++)
{
if(a[j]=='(')
b[j]='$';
else if(a[j]==')')
b[j]='?';
else b[j]=' ';
}
// puts(b);
for(j=1;j<k;j++)
{
if(b[j]=='?')
{
for(m=j-1;m>=0;m--)
if(b[m]=='$')
{
b[m]=' ';
b[j]=' ';
break;
}
}
}
printf("%s\n%s\n",a,b); }
}
| 17 |
8,197 | void pipei(char str[])
{
int i,la,stack[100],k=0;
char res[101];
la=strlen(str);
for(i=0;i<la;i++) res[i]=' ';
res[la]='\0';
for(i=0;i<la;i++)
{
if(str[i]==')')
{
if(k==0||stack[k-1]>0)
stack[k++]=i+1;
else k--;
}
else if(str[i]=='(')
stack[k++]=-(i+1);
}
for(i=0;i<k;i++)
{
int a=stack[i];
if(a<0) res[-a-1]='$';
else res[a-1]='?';
}
cout<<str<<endl;
cout<<res<<endl;
}
int main()
{
int n,i;
cin>>n;
cin.get();
char str[101];
for(i=0;i<n;i++)
{
cin.getline(str,101);
pipei(str);
}
return 0;
}
| 17 |
8,198 | int main()
{
while(true)
{
char a[110]={'\0'},b[110]={'\0'};
int i=0;
char x='\0';
while(true)
{
x=getchar();
if(x=='\n')break;
a[i]=x;
b[i]=x;
i++;
}
int k=1,j,n;
while(k<i)
{
for(j=0;j<i-k;j++)
{
int zhongjian=0,l;
if(k!=1)
{
for(l=j+1;l<j+k;l++)
{
if(a[l]=='(' || a[l]==')')zhongjian=1;
}
}
if(a[j]=='(' && a[j+k]==')' && zhongjian==0)
{
a[j]='\0';
a[j+k]='\0';
}
}
k=k+1;
}
for(n=0;n<i;n++)
{
if(a[n]=='(')a[n]='$';
else if(a[n]==')')a[n]='?';
else a[n]=' ';
}
for(n=0;n<i;n++)cout<<b[n];
cout<<endl;
for(n=0;n<i;n++)cout<<a[n];
cout<<endl;
}
return 0;
} | 17 |
8,199 | int main()
{
int n,i,j,k,l;
char a[100][120];
scanf("%d",&n);
getchar();
for(i=0;i<n;i++)
{
gets(a[i]);
puts(a[i]);
k=strlen(a[i]);
for(j=0;j<k;j++)
{
if(a[i][j]==')')
{
a[i][j]='?';
}
if(a[i][j]=='(')
{
a[i][j]='$';
}
}
for(j=0;j<k;j++)
{
if(a[i][j]!='?'&&a[i][j]!='$')
{
a[i][j]=' ';
}
}
for(j=0;j<k;j++)
{
if(a[i][j]=='?')
{
for(l=j;l>=0;l--)
{
if(a[i][l]=='$')
{
a[i][j]=' ';
a[i][l]=' ';
break;
}
}
}
}
for(j=0;j<k;j++)
{
printf("%c",a[i][j]);
}
printf("\n");
}
return 0;
} | 17 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.