littlewhite_ @ 2023-09-22 18:12:46
#include <iostream>
using namespace std;
char s1[100], s2[100];
int main()
{
int t = 0;
cin >> s1;
int i = 0;
while (s1[i] != '\0')
{
if(s1[i] == '(')
{
cout << s1[i];
s2[t] = s1[i];
t++;
}
if(s1[i] == ')')
{
if(t != 0)
{
cout << s1[i];
t--;
}
else
{
cout << "(" << s1[i];
}
}
i++;
}
while(t != 0)
{
cout << ")";
t--;
}
return 0;
}
by Soojin2012 @ 2023-09-22 18:42:57
数组开大点
by QCurium @ 2023-09-22 18:47:31
by littlewhite_ @ 2023-09-22 18:51:44
@zhengshuyue 谢谢!!!
by littlewhite_ @ 2023-09-22 18:52:10
@quchenming 谢谢!!!