Trangleproble Switch Method java

Source: Internet
Author: User

1  Public classTrangleproblem {2 3     Static intRes=1;4     intCodepart=1;5     intn=100;6Stack<param> stack=NewStack<param>();7      Public Static voidMain (string[] args) {8Trangleproblem tb=NewTrangleproblem ();9          while(Tb.solve () = =false)Ten             ; One     } A  -      Public BooleanSolve () -     { the          -      -         Switch(Codepart) -         { +          Case1:stack.push (NewParam (N, 6)); -codepart=2; +                  Break; A          Case2: at                 if(Stack.peek (). nn==1) -Codepart=5; -                 Else -Codepart=3; -                  Break; -          Case3:stack.push (NewParam (Stack.peek (). nn-1, 4)); incodepart=2; -                  Break; to          Case4:res+=Stack.peek (). nn; +Codepart=5; -                  Break; the          Case5:codepart=Stack.peek (). ReturnAddress; * Stack.pop (); $                  Break;Panax Notoginseng          Case6: -                 return true; the                  +          A         } the         return false; +     } -  $ } $ classParam - { -     intnn; the     intReturnAddress; -Param (intNnintreturnaddress)Wuyi     { the          This. nn=nn; -          This. returnaddress=ReturnAddress; Wu     } -}

Trangleproble Switch Method java

Related Article

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.