#include<iostream>#include<stack>#include<string>using namespace std;// )(rttyy())sss)(int main(){string str1;while(getline(cin, str1)){// 获取输入cout<<str1<<endl;stack<char> MyStack;stack<int> IndexStack;string str2;for(int i = 0; i < str1.size(); i++){str2 += &quot; &quot;;}for(int i = 0; i < str1.size(); i++){char target = str1[i];if(target == '('){// 左括号直接入栈MyStack.push(target);IndexStack.push(i);} else if (target == ')'){if(MyStack.empty()){ // 不能匹配的右括号str2[i] = '?';} else if(MyStack.top() == '('){// 右括号与左括号消去MyStack.pop();IndexStack.pop();} else { // 不能匹配的右括号str2[i] = '?';}} else {str2[i] = ' ';}}// 寻找不能匹配的左括号int size = IndexStack.size();int index;for(int i = 0; i < size; i++){index = IndexStack.top();IndexStack.pop();str2[index] = '$';}cout<<str2<<endl;}}