/***************** Determine whether pop is a legal sequence of the SRC stack ************ * ***************/bool ispopseq (string SRC, string pop) {stack <char> Sch; int Len = pop. length (); If (SRC. length ()! = Pop. length () return false; For (INT I = 0; I <Len; I ++) {int idx = SRC. find (POP [I]); If (idx = string: NPOs & Sch. empty () // return false if the initial sequence cannot be found and the stack is empty; else if (idx! = String: NPOs) {// if it is found in the initial sequence, the subsequent characters will be added to the stack in sequence, and the top element will be thrown out for (Int J = 0; j <= idx; j ++) Sch. push (SRC [J]); SRC. erase (SRC. begin (), SRC. begin () + idx + 1); Sch. pop ();} else if (idx = string: NPOs &&! Sch. Empty () {// if the initial sequence cannot be found and the stack is not empty, compare whether the top element of the stack is equal to the elements of the output stack sequence. If they are not equal, the result is invalid. Char CH = Sch. top (); If (CH = pop [I]) Sch. pop (); elsereturn false ;}} return true ;}# define judgeseq (SRC, pop) \ If (ispo1_q (SRC, pop )) cout <"is a valid seq" <Endl; \ else cout <"is a invalid seq" <Endl;