资 源 简 介
« 问题描述:在对高级语言编写的程序进行编译时会遇到表达式或字符串的括号匹配问题。例如C++程序中左、右花括号“{”和“}”的匹配问题。表达式(字符串)的括号匹配问题要求确定一给定表达式(字符串)中左、右括号的匹配情况。例如,表达式(x*(x+y)-z)在位置1 和4处有左括号,在位置8 和11 处有右括号。位置1 处的左括号与位置11 处的右括号相匹配;位置4 处的左括号与位置8 处的右括号相匹配。而在表达式(x+y)*z)(中,位置8处的右括号没有可匹配的左括号,位置9处的左括号没有可匹配的右括号。« 编程任务:给定一个C++源程序,编程计算其中括号“”;“(”和“)”;“[”和“]”;“{”和“}”的匹配情况-laquo; Problem description : In preparation for the high-level language compiler procedures that will be encountered expression or string matching brackets. C procedures such as left and right curly "(" and ")" matching problem. Expression (string), the brackets matching requirement to set a fixed expression (string) left and right brackets of the match. For example, the expression (x* (x y)- z) in a position and have left four brackets in position 8 and 11 have the right brackets. A position on the left with brackets of 11 positions in brackets right match; Location four brackets on the left and the location of eight brackets right match. The expr