| ||||||||||
| 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 <stdio.h>
int main()
{
int a,b,c,d,e,f,g,top=5;
char l[7000],*s=l;
int i[7000]={0};
gets(s);
for(;*s;s++)
{
switch(*s)
{
case'(':
i[top]=1;
top++;
break;
case'[':
i[top]=2;
top++;
break;
case')':
if(i[top-1]==1)
{
top--;
break;
}
else if(i[top-1]==2)
{
printf("]");
top--;
if(i[top-1]!=1)
printf("(");
else top--;
break;
}
else
{
printf("(");
break;
}
case']':
if(i[top-1]==2)
{
top--;
break;
}
else if(i[top-1]==1)
{
printf(")");
top--;
if(i[top-1]!=2)
printf("[");
else
top--;
break;
}
else
{
printf("[");
break;
}
}
printf("%c",*s);
}
for(b=top-1;b>=5;b--)
{
if(i[b]==2)
{
printf("]");
top--;
}
if(i[b]==1)
{
printf(")");
top--;
}
}
printf("\n");
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator