IMOOC data structure adventure-stack stack application bracket matching two by group friends to inspire improved James_yuan teacher algorithm

Source: Internet
Author: User
Tags print bracket

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.