Welcome![Sign In][Sign Up]
Location:
Search - brackets parantheses algorithm

Search list

[DocumentsMatching-brackets

Description: 数据结构 1、算法思路: 假设表达式中包含两种括号:圆括号和方括号,其嵌套顺序随意,即([]())或[([])]等为正确的格式,[(])或([())或(()]均为不正确的格式。检验括号是否匹配可以用堆栈来实现当遇到 ( 或 [ 时进栈,遇到 ) 或 ] 时出栈进行匹配检验,如果出现不匹配的情况立即结束,否则继续取下一个字符。如果没有遇到不匹配的情况,最后判断栈是否为空,栈为空,括号匹配,否则不匹配。 -Data Structure 1, Algorithm idea: the assumption that the expression contains two types of brackets: parentheses and brackets, the nested sequence of random, that is, or ([]()) [([])] such as the correct format, [( ]) or ([()) or (()] are not the correct format. test match brackets can be used to achieve when the stack (or [into the stack when encountered) or] when a stack test match , if the situation does not match an immediate end to, or continue to remove a character. If you do not encounter the situation does not match, the last to judge whether the stack is empty, the stack is empty, parentheses matching, otherwise do not match.
Platform: | Size: 13312 | Author: Anson | Hits:

CodeBus www.codebus.net