笔记草稿
地址:笔记草稿
注意:这里需要考虑多括号的问题。
#include <iostream>
#include <stack>
#include <string>
using namespace std;
string showString(string &str)
{
string res;
for(int i = 0; i < str.size(); i++)
{
stack<char> s;
if(str[i] == '(')
{
s.push(str[i]);
while(!s.empty())
{
i++;
if(str[i] == '(')
s.push(str[i]);
else if(str[i] == ')')
s.pop();
}
}
else if(str[i] == '<')
{
res = res.substr(0, res.size()-1);
}
else
res += str[i];
}
return res;
}
int main()
{
string str;
getline(cin, str);
cout << showString(str) << endl;
return 0;
}