#include#include#includeusing namespace std;// )(rttyy())sss)(int main(){string str1;while(getline(cin, str1)){// 获取输入 coutstack MyStack;stack IndexStack;string str2;for(int i = 0; i str2 += " ";}for(int i = 0; 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 index = IndexStack.top();IndexStack.pop();str2[index] = '$';}cout}}#牛客AI配图神器#