#include<iostream>
#include<cstring>
using namespace std;
int main()
{
char s[110];
int v[110];
while(cin.getline(s,110))
{
for(int i=0;i<strlen(s);i++)
{
if(s[i]=='(')
v[i] = 1;
else if(s[i]==')')
v[i] = -1;
else
v[i] = 0;
}
for(int i=0;i<strlen(s);i++)
{
if(v[i]==-1)
for(int j=i-1;j>=0;j--)
if(v[j]==1)
{
v[i] = 0;
v[j] = 0;
break;
}
}
cout<<s<<endl;
for(int i=0;i<strlen(s);i++)
{
if(v[i]==1)
cout<<"$";
else if(v[i]==-1)
cout<<"?";
else
cout<<" ";
}
cout<<endl;
}
return 0;
}
poj 3704:擴號匹配問題
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.