首页
DreamJudge
院校信息
考研初试
机试真题
讨论区
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
RingoCrystal
2024年3月30日 11:11
括号的匹配 题解:想问一下大佬为什么只能过20%
P1067
回复 1
|
赞 6
|
浏览 1.2k
#include <bits/stdc++.h> using namespace std; int level(char a){ int level; if(a=='<')level=1; else if(a=='(')level=2; else if(a=='[')level=3; else if(a=='{')level=4; else level=5; return level; } int main(){ int n; while(cin>>...
Cookie‘s AE86
2024年3月23日 15:23
括号的匹配 题解:用的stl中的stack,总是报错Process t
P1067
回复 2
|
赞 0
|
浏览 991
#include<bits/stdc++.h> using namespace std; //设置括弧的优先级 map<char,int> bkPriority = { {'<', 0}, {'(', 1}, {'[', 2}, {'{', 3} }; //设置括弧的匹配 map<char,char> bkMatch = { {'>', '<'}, {')', '('}, {']', '['}, {'}', '{'} }; bool match(string s){ ...
easymoney
2024年3月23日 15:23
括号的匹配 题解:
P1067
回复 0
|
赞 4
|
浏览 1.1k
#include <stdio.h> #include <iostream> #include <algorithm> #include <stack> #include <string> using namespace std; int main(){ int val[127]; int n; val['<'] = 1,val['('] = 2,val['['] = 3,val['{'] = 4; cin >> n; while(n--){ string str; ...
huanghu
2024年3月11日 00:40
括号的匹配 题解:利用map来控制优先级
P1067
回复 0
|
赞 10
|
浏览 1.3k
#include<stdio.h> #include<iostream> #include<stack> #include<map> using namespace std; int main(){ stack<char> stk; map<char,int> priority = { {'<',1}, {'(',2}, {'[',3}, {'{',4} }; //如果入栈元素的优先...
799
2024年3月9日 22:02
括号的匹配 题解:
P1067
回复 0
|
赞 2
|
浏览 1.1k
#include<bits/stdc++.h> using namespace std; void pd(string s); int main() { /* 1、使用stak栈模拟匹配括号,[] () {} <> {[(<>)]}; 将数组s中括号放入栈p中 2、如果栈顶部元素与下一个入栈元素匹配:"(" 与 ")",或者"["与"]",则出栈,反之入栈 ...
1935569240
2024年3月7日 16:35
括号的匹配 题解:简单的来了哦
P1067
回复 0
|
赞 1
|
浏览 1.2k
#include<iostream> #include<algorithm> #include<stack> #include<string> using namespace std; int main() { int n,cnt=0; cin >> n; stack<char> stac; string ans[100]; &n...
孙某人
2024年2月18日 20:21
括号的匹配 题解:新手方法简单易懂
P1067
回复 0
|
赞 6
|
浏览 1.4k
#include <iostream> #include <string.h> using namespace std; int main(){ int n,cc=0,num=0,top=-1,flag=0; char now; cin >>n; char stack[300];char b[105][300];char c[105][10]; for(int i=0;i<105;i++)for(int j=0;j<300;j++) b[i][j]=0; for(int i=0;i<105;i++)f...
小王桐学
2024年2月2日 14:52
括号的匹配 题解:C有点麻烦
P1067
回复 0
|
赞 3
|
浏览 1.3k
#include <stdio.h> #include <string.h> int main() { int n,i,j = 0,k,a[100],top,flag;//a数组为标记数组,flag为标记 char s[255],tt[255],c;//tt数组为栈 scanf("%d",&n); for(i = 0 ; i < n; i++) { top = -1;//栈顶指针 k = 0; flag = 0; scanf("%s",s); while(s[k] != '\0')//...
Beyong
2024年1月18日 23:56
括号的匹配 题解:
P1067
回复 0
|
赞 1
|
浏览 850
// // Created by Beyong on 2024/1/18. // #include<iostream> #include<stack> using namespace std; int char_weight(char s); int main() { int n = 5; cin >> n; cin.ignore(); while (n) { string str; bool flag = true; getline(cin, str); stack<char> stack...
Syou
2023年8月22日 11:29
括号的匹配 题解:C++ <stack>
P1067
回复 0
|
赞 3
|
浏览 1.6k
C++ 分别考虑8种括号 #include <iostream> #include <string> #include <stack> using namespace std; bool isMatched(string str){ stack<char> chars; for(int j = 0; j < str.size(); j++){ if(str[j] == '<'){ chars.push(str[j]); } ...
1
2
3
4
题目
括号的匹配
题解数量
36
发布题解
在线答疑
热门题解
1
括号的匹配 题解:c++ stl中的stack容器和map容器实现。
2
再定义一个优先级栈,出栈的时候判断
3
题目坑点
4
括号的匹配 题解:
5
括号的匹配 题解:左压右出,四种错误情况
6
括号的匹配 题解:用栈解决
7
括号的匹配 题解:利用map来控制优先级
8
括号的匹配 题解:111
9
括号的匹配 题解:想问一下大佬为什么只能过20%
10
括号的匹配 题解:新手方法简单易懂