首页
DreamJudge
院校信息
考研初试
考研复试
保研专区
讨论区
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
userCao
2026年3月19日 15:43
括号匹配 题解:C语言实现
P1501
回复 0
|
赞 0
|
浏览 7
#include<stdio.h> #include <string.h> #define MAX 100 int main() { char str[MAX]={'\0'}; scanf("%s",str);//输入字符串 int len=strlen(str); char stack[MAX];//模拟栈出入括号 int...
18919717626
2026年3月17日 11:42
括号匹配 题解:
P1501
回复 0
|
赞 1
|
浏览 27
#include<iostream> #include<stack> using namespace std; int main(){ stack<char> stk; string s; int i = 0; cin >> s; bool ismatch = true; for(int i = 0...
ZeroQi_404
2026年3月15日 21:59
括号匹配 题解:
P1501
回复 0
|
赞 5
|
浏览 42
#include <iostream> #include <stack> using namespace std; int main(){ string s; cin >> s; stack<char> st; for(int i=0;i<s.size();i++){ if(s[i]=='(' || s[i]=='['){ st.push(s[i]); } else{ if(st.empty()){ cout << "NO"; ...
Tyu0871
2026年3月12日 16:30
括号匹配 题解:依旧进栈出栈
P1501
回复 0
|
赞 3
|
浏览 110
#include<bits/stdc++.h> #include<stack> using namespace std; int main(){ string ss; getline(cin,ss); if(ss.size()%2!=0) { cout<<"NO"; return 0; } bool flag = true;//标记一处地点 stack<char> s1; for(int i=0;i<=ss.size();i++){//屎山判断,符号栈进栈出栈....
Jinx_K
2026年3月11日 16:40
括号匹配 题解:natural thinking
P1501
回复 0
|
赞 1
|
浏览 42
#include <bits/stdc++.h> using namespace std; int main() { stack<char> st; string s; cin>>s; int mark=1; for(int i=0;i<s.size();i++) { if(s[i]=='['||s[i]=='(') st.push(s[i]); else if(!st.empty()) { char t=st.top(); if((s[i]-t==')'-'(')|...
岸上的乌龟
2026年3月1日 10:47
括号匹配 题解:75通过率原因
P1501
回复 0
|
赞 8
|
浏览 150
当输入字符串以右括号开头时(如")"或"]"),栈为空状态下执行S.top()会导致运行时错误 #include <bits/stdc++.h> using namespace std; int main() { stack<int> S; string s; cin>>s; int len=s.length(); char x; &nb...
bro
2026年2月25日 14:38
括号匹配 题解:c++
P1501
回复 0
|
赞 10
|
浏览 161
#include <bits/stdc++.h> using namespace std; stack<char> S; int main(){ string str; cin >> str; for(int i = 0; i < str.size(); i++){ if(S.empty()) S.push...
sadhjksdj
2026年2月20日 15:46
括号匹配 题解:
P1501
回复 0
|
赞 1
|
浏览 130
#include<bits/stdc++.h> using namespace std; //左括号进栈,右括号和栈顶进行匹配进行出栈,不用一直匹配下去遇到中途有不合法直接退出遍历 int main(){ stack<char> arr; string s; cin>>s; int len = s.length(); if(len%2 == 1){ ...
langlang23
2026年2月10日 17:05
括号匹配 题解:
P1501
回复 0
|
赞 2
|
浏览 105
注意点:首个元素直接入栈、非空才开始判断是否左括号且入栈,是为了避免各种异常处理,以及匹配成功时 pop 不溢出。 #include <bits/stdc++.h> using namespace std; int main(){ string s; while(getline(cin , s)){ stack<char> st; for(int i = 0; i < s.size(); i++){ if(!st.empty()){ ...
xsw
2026年2月8日 11:46
括号匹配 题解:
P1501
回复 0
|
赞 4
|
浏览 161
#include<iostream> #include<stack> using namespace std; int main() { stack<char> s; string str; cin >> str; for (int i = 0; i < str.size(); i ++ ) { if (str[i] == '(' || str[i] == '[') s.push(str[i]); else { if (s.empty()) { puts("NO"); ...
1
2
3
4
题目
括号匹配
题解数量
38
发布题解
在线答疑
热门题解
1
括号匹配 题解:简单之中亦有坑
2
括号匹配(C++ string栈) 题解:
3
1501 括号匹配 栈经典题
4
括号匹配 题解:stack
5
括号匹配 题解:c++
6
Runtime Error 通过75%
7
括号匹配 题解:75通过率原因
8
括号匹配 题解:用数组来模拟栈+知识点总结图示
9
括号匹配 题解:求大佬解惑,显示runtime error,75%数据通过
10
括号匹配 题解: