Sequence stack [cpp] # include <stdio. h> // initialize the stack [sequential Stack] void initStack (SeqStack * s) {s-> top =-1 ;}// stack-in-stack int push (SeqStack * s, stackElementType x) {if (s-> top = Stack_size-1) {return false;} s-> top +; s-> elem [s-> top] = x; return true;} // output stack int Pop (SeqStack * s, StackElementType * x) {if (s-> top =-1) {return false ;} else {* x = s-> elem [s-> top]; s-> top --; return true ;}// get the top element of the stack int GetTop (SeqStack * s, stackElementType * X) {if (s-> top =-1) {return false;} else {* x = s-> elem [s-> top]; return true ;}} int main (void) {return 0;} chain stack [cpp] # include <stdio. h> typedef struct node {StackElementType data; struct node * next;} LinkStackNode; typedef LinkStackNode * LinkStack; // stack-in-stack [Chain Stack] int push (SeqStack top, StackElementType x) {LinkStackNode * temp; temp = (LinkStackNode) malloc (sizeof (LinkStackNode); if (temp = NULL )// Failed to apply for space return false; temp-> data = x; temp-> next = top-> next; top-> next = temp; return true ;} // output stack [Chain Stack] int Pop (SeqStack top, StackElementType * x) {LinkStackNode * temp; temp = top-> next; if (temp = NULL) // stack is empty return false; top-> next = temp-> next; * x = temp-> data; free (temp); return true;} int main (void) {return 0;} brackets matching algorithm [cpp] # include <stdio. h> // bracket matching algorithm void BracketMatch (char * str) // The input string {Stack s, int I, Char ch; InitStack (& s); for (I = 0; str [I]! = '\ 0'; I ++) {switch (str [I]) {case' (': case' [': case' {': Push (& s, str [I]); break; case ')': case ']': case '}': if (IsEmpty (& s )) {printf ("unnecessary parentheses"); return;} else {GetTop (& s, & ch); if (Match (ch, str [I]) pop (& s, & ch); else printf ("corresponding to different bracket classes");} www.2cto.com} if (IsEmpty (& s )) printf ("Parentheses match"); else printf ("Parentheses do not match");} int main (void) {return 0 ;}