Brand matching (stack)

xiaoxiao2021-03-05  26

const Int Maxlength = 100; Void PrintMatch (CHAR * EXPR) {Stack S (Maxlength); INT J, Length = Strlen (Expr); for (INT i = 1; I <= Length; i ) {IF EXPR [I-1] == '(') S.Add (i); ELSE IF (expr [i-1] == ')') {s.delete (j); cout << j << '' << I << endl;}} // The remaining in the stack (all unmapled While (!! s.Isempty ()) {s.delete (j); cout << "no match for Left Parenthesis At << j << endl;}}

Ref: << Data Structure, Algorithm & Applications >> P169 ~ 170

转载请注明原文地址:https://www.9cbs.com/read-32238.html

New Post(0)