youngsmart @ 2023-11-10 22:34:42
#include <iostream>
#include <stack>
using namespace std;
stack <char> stk;
int main()
{
string s;
cin >> s;
for (int i = 0; i != s.size(); i++)
{
stk.push(s[i]);
}
while (!stk.empty())
{
char ch = stk.top();
stk.pop();
if (ch == ')')
{
if (stk.top() == '(')
{
stk.pop();
}
else
{
cout << "()";
}
cout << "()";
}
else if (ch == '(')
{
cout << "()";
}
else if (ch == ']')
{
if (stk.top() == '[')
{
stk.pop();
}
else
{
cout << "[]";
}
cout << "[]";
}
else
{
cout << "[]";
}
}
return 0;
}
by youngsmart @ 2023-11-10 22:37:07
评测点wa+re