Eighth session Blue Bridge Cup JAVA (Group B) Second question "Solitaire triangle"

Source: Internet
Author: User

classcarddelta{intTop=1; intLeft=3; intright=2; /*A 9 6 4 8 3 7 5 2 **/     PublicCarddelta () {} Public voidSort3num () { for(inti = 1; I < 8; i++) {             for(intj = i+1; J < 9; J + +) {                 for(intK = j+1; K < 10; k++) {                    //System.out.println ("+i+j+k"); //The value of three fixed points is determined in this loop and then passed into a function//traversal of all nodes in a functionRunover (I, J, K); }            }        }    }     Public voidRunover (intTopintLeftintRight ) {        intL1, L2, R1, r2, T1, T2; intTag=0;  for(L1 = 1; L1 < l1++) {            if(L1!=top && l1!=left && l1!=Right ) {                 for(l2=1; l2<10; l2++) {                    if(L2==l1 | | (L2==top | | l2==left | | l2==Right )) {                        Continue; }                     for(R1=1, R1 < r1++) {                        if(r1==l1 | | r1==l2 | | (R1==top | | r1==left | | r1==Right )) {                            Continue; }                         for(R2=1, R2 < r2++) {                            if(r2==r1 | | r2==l1 | | r2==l2 | | (R2==top | | r2==left | | r2==Right )) {                                Continue; }                             for(T1=1, T1 < t1++) {                                if(t1==r1 | | t1==l1 | | t1==l2 | | (T1==top | | t1==left | | t1==Right )) {                                    Continue; }                                 for(T2=1, T2 < t2++) {                                    if(t2==r1 | | t2==l1 | | t2==l2 | | (T2==top | | t2==left | | t2==Right )) {                                        Continue; }                                    if(Left+l1+l2+top = = Top+r1+r2+right && Top+r1+r2+right = = left+t1+t2+Right ) {Tag++; System.out.println ("Left:" +left+l1+l2+top+ "\nright:" +top+r1+r2+right+ "\ndown:" +left+t1+t2+Right );                                    }                                }                            }                        }                    }    }}} System.out.println (tag); }} Public classjava17_2 { Public Static voidMain (string[] args) {//TODO auto-generated Method StubCarddelta Cdelta =NewCarddelta ();    Cdelta.sort3num (); }}

Eighth session Blue Bridge Cup JAVA (Group B) Second question "Solitaire triangle"

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.