#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void main()
{
char str[101];
while(scanf("%s",str)!=EOF)
{
int i=0;
char stack[101];
int p=-1;
char ans[101];
for(i=0;str[i]!=0;i++)
{
if(str[i]=='(')
{
stack[++p]=i;
ans[i]=' ';
}
else if(str[i]==')')
{
if(p!=-1)
{
stack[p--];
ans[i]=' ';
}
else ans[i]='?';
}
else ans[i]=' ';
}
while(p!=-1)
{
ans[stack[p]]='$';
p--;
}
ans[i]=0;
puts(str);
puts(ans);
}
}
题目26:括号匹配问题
最新推荐文章于 2021-10-11 12:25:38 发布