Reference Group Friends Content
Teacher code A little trouble, do not declare two mystack, directly determine whether it is an opening parenthesis,
Yes, in Mystack. Push the other half bracket, if it is a closing parenthesis and not the required parentheses,
Just print the mismatch, if the right parenthesis is needed, pop out the left parenthesis. Finally see if the top of the Mystack is 0, and 0 is the print bracket.
/*
The teacher last point is actually wrong, the default is actually not necessary to write, as long as the Pneedstack->pop (currentneed) changed to
if (!pneedstack->pop (currentneed))
{
Currentneed=0;
}
That's enough, the first time you enter "" () "" "Displays the error because, when you loop to the second-to-last character,
Pneedstack stack empty causes pneedstack->pop (currentneed) to return a false,currentneed not placed in 0, still "" ",
Causes the loop to the last character when Str[4]==currentneed,str[4] is not in the stack, and the pstack is finally empty to make an error. Put Crrentneed in 0.
*/
IMOOC data structure adventure-stack stack application bracket matching two by group friends to inspire improved James_yuan teacher algorithm