文章
37
粉丝
98
获赞
4
访问
22.8k
#include<iostream>
#include<algorithm>
#include<stack>
#include<string>
using namespace std;
int main()
{
stack<char> stac;
string s;
cin >> s;
int len = s.size();
for (int i = 0; i < len; i++) {
if (!stac.empty()) {
char now = stac.top();
if ((s[i] == ')' && now == '(') || (s[i] == ']' && now == '[')) {//匹配成功,出栈
stac.pop();
}
else {
stac.push(s[i]);
&nbs...
登录后发布评论
暂无评论,来抢沙发