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"