首页
DreamJudge
院校信息
考研初试
考研复试
保研专区
讨论区
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
奶龙大王
2026年1月27日 15:47
括号的匹配 题解:
P1067
回复 0
|
赞 5
|
浏览 222
Map定义层级和存储括号对,stack出入匹配括号 #include <iostream> #include <stack> #include <map> #include <string> using namespace std; int main() { int n; cin >> n; string line; getline(cin, line); // cons...
mlx
2026年1月26日 19:43
括号的匹配 题解:
P1067
回复 0
|
赞 3
|
浏览 198
#include<iostream> #include<stack> using namespace std; int n; string str; bool check() { stack<char> st; for(int i=0;i<str.size();i++) { if(str[i]=='{') { if(st.empty()) st.push(str[i]); else { if(st.top()=='['||st.top()=...
曾不会
2026年1月25日 11:29
括号的匹配 题解:
P1067
回复 0
|
赞 1
|
浏览 136
栈 #include<stdio.h> #include<stack> #include<string.h> using namespace std; int main() { int n; scanf("%d",&n); getchar(); while(n--) { &...
cczz
2025年8月11日 17:39
括号的匹配 题解(stack和map容器):
P1067
回复 0
|
赞 35
|
浏览 1.1k
#include<bits/stdc++.h> using namespace std; map<char, int> rk = {{'{', 4}, {'[', 3}, {'(', 2}, {'<', 1}}; map<char, char> match = {{'}', '{'}, {']', '['}, {')', '('}, {'>', '<'}}; string judge(string s){ stack<char> st; for(char &ch : s){ ...
leo110
2025年5月17日 15:58
括号的匹配 题解:"{{}}"这种平级括号内嵌也行!!!
P1067
回复 0
|
赞 4
|
浏览 1.0k
//解题思路:map映射字符为整数,结合数据结构的stack进行括号匹配。 #include<iostream> #include<map> #include<stack> using namespace std; map<char,int> Bracket={{'{',-4},{'[',-3},{'(',-2},{'<',-1},{'>',1},{')',2},{']',3},{'}...
GENARDING
2025年3月20日 17:30
再定义一个优先级栈,出栈的时候判断
P1067
回复 0
|
赞 39
|
浏览 1.3k
#include <bits/stdc++.h> using namespace std; // 大括号 > 中括号 > 小括号 > 尖括号 int priority(char c) { if (c == '{' || c == '}') return 1; if (c == '[' || c == ']') return 2; if (c == '(' || c == ')') return 3; if (c == '<' || c == '>') return 4; return...
bubble362
2025年3月19日 16:27
括号的匹配 题解:
P1067
回复 0
|
赞 9
|
浏览 1.3k
#include<iostream> #include<algorithm> #include<math.h> #include<ctype.h> #include<stack> #include<stdlib.h> #include<cstring> #include<queue> #include<map> using namespace std; map<char, int> fh = { {'{', 4}, {'[', ...
西电机试专家
2025年3月14日 14:57
括号的匹配 题解:111
P1067
回复 0
|
赞 9
|
浏览 1.3k
#include <bits/stdc++.h> using namespace std; map<char,char> m1{ {'>','<'},{')','('},{']','['},{'}','{'} }; map<char,int> m2{ {'<',1},{'(',2},{'[',3},{'{',4} }; void ...
csYfZhang
2020年5月10日 12:10
题目坑点
P1067
回复 3
|
赞 28
|
浏览 13.0k
注意括号的嵌套,同级是可以互相嵌套的{{}}是对的 #include<iostream> #include<stack> #include<string> #include<string.h> using namespace std; bool cmp(char s1, char s2) { if (s1 == '<')s1 = 20; if (s2 == '<')s2 = 20; return s1 <= s2; } int main() { int n; cin >...
zxjrheaven
2025年3月12日 15:54
括号的匹配 题解:假设你这个人很头铁,不使用任何容器(包括stack和
P1067
回复 0
|
赞 7
|
浏览 1.2k
#include <bits/stdc++.h> using namespace std; int get_rank(char c) { if (c == '{') return 4; else if (c == '[') return 3; else if (c == '(') return 2; else if (c == '<') return 1; &nbs...
1
2
3
4
5
题目
括号的匹配
题解数量
50
发布题解
在线答疑
热门题解
1
括号的匹配 题解:c++ stl中的stack容器和map容器实现。
2
再定义一个优先级栈,出栈的时候判断
3
括号的匹配 题解(stack和map容器):
4
题目坑点
5
括号的匹配 题解:map搞个优先级
6
括号的匹配 题解:
7
括号的匹配 题解:左压右出,四种错误情况
8
括号的匹配 题解:匹配判断,优先级判断,注意栈空情况
9
括号的匹配 C语言题解:利用优先值和栈
10
括号的匹配 题解: