CodePudding user response:
Public class test {
Public static void main (String [] args) {
Int [] n={3, 2, 1, 2, 3};
BeforeThree (n [0], n [1], n [2]).
MiddleThree (n [1], n [2], n [3]).
AfterThree (n [2], n [3], [4] n);
}
Public static void beforeThree (int a, b int, int) c {
If (leopard (a, b, c) {
System. The out. Println (" in the first three, the leopard ");
} else if (symmetry (a, c)) {
System. The out. Println (" pair in the first three, ");
} else if (continuous) (a, b, c) {
System. The out. Println (" in the first three, shunza ");
} else if (halfCntinuous (a, b, c) {
System. The out. Println (" before the three and a half, shun ");
} else {
System. The out. Println (" in the first three, miscellaneous six ");
}
}
Public static void middleThree (int a, b int, int) c {
If (leopard (a, b, c) {
System. The out. Println (" in three, a leopard ");
} else if (symmetry (a, c)) {
System. The out. Println (" pair of three, ");
} else if (continuous) (a, b, c) {
System. The out. Println (" in three, shunza ");
} else if (halfCntinuous (a, b, c) {
System. The out. Println (" in three, half down ");
} else {
System. The out. Println (" in three, miscellaneous six ");
}
}
Public static void afterThree (int a, b int, int) c {
If (leopard (a, b, c) {
System. The out. Println (" after three, leopard ");
} else if (symmetry (a, c)) {
System. The out. Println (" pair after three, ");
} else if (continuous) (a, b, c) {
System. The out. Println (" after three, shunza ");
} else if (halfCntinuous (a, b, c) {
System. Out. Println (" after three, half down ");
} else {
System. The out. Println (" after three, miscellaneous six ");
}
}
/* *
* determine whether the leopard
*
* @ return
*/
Public static Boolean leopard (int a, b int, int) c {
Return (a==b & amp; & B==c)? True, false;
}
/* *
* determine whether pairs (personal understanding on both sides of the same number)
*
* @ return
*/
Public static Boolean symmetry (int a, c) int {
Return a==c? True, false;
}
/* *
* determine whether shunza, this said it was only shunza, did not say so don't shun such as 321 topics for design, half along in the same way, the suitable all classified as miscellaneous.
*
* @ return
*/
Public static Boolean continuous (int a, b int, int) c {
Return (a==b - 1 & amp; & B==c - 1)? True, false;
}
/* *
* determine whether half down
*
* @ return
*/
Public static Boolean halfCntinuous (int a, b int, int) c {
Return (a==b - 1 | |=b=c - 1 & amp; & A!!!!=c)? True, false;
}
}
CodePudding user response:
To simplify the code
Public class test {
Public static void main (String [] args) {
Int [] n={1, 2, 3, 2, 3};
System. The out. Println (" in the first three, "+ getResult (n [0], n [1], n [2]));
System. The out. Println (" three, "+ getResult (n [1], [2] n, n [3]));
System. Out. Println (" 3, after "+ getResult (n [2], [3] n, n [4]));
}
Public static String getResult (int a, b int, int) c {
If (leopard (a, b, c) {
Return "the leopard";
} else if (symmetry (a, c)) {
Return "subsidiary";
} else if (continuous) (a, b, c) {
Return "shunza;"
} else if (halfCntinuous (a, b, c) {
Return "half shun";
} else {
Return "miscellaneous six";
}
}
/* *
* determine whether the leopard
*
* @ return
*/
Public static Boolean leopard (int a, b int, int) c {
Return (a==b & amp; & B==c)? True, false;
}
/* *
* determine whether pairs (personal understanding on both sides of the same number)
*
* @ return
*/
Public static Boolean symmetry (int a, c) int {
Return a==c? True, false;
}
/* *
* determine whether shunza, this said it was only shunza, did not say so don't shun such as 321 topics for design, half along in the same way, the suitable all classified as miscellaneous.
*
* @ return
*/
Public static Boolean continuous (int a, b int, int) c {
Return (a==b - 1 & amp; & B==c - 1)? True, false;
}
/* *
* determine whether half down
*
* @ return
*/
Public static Boolean halfCntinuous (int a, b int, int) c {
Return (a==b - 1 | |=b=c - 1 & amp; & A!!!!=c)? True, false;
}
}
CodePudding user response:
Public class test {
Public static void main (String [] args) {
Int [] n={1, 2, 3, 2, 3};
System. The out. Println (" in the first three, "+ getResult (n [0], n [1], n [2]));
System. The out. Println (" three, "+ getResult (n [1], [2] n, n [3]));
System. Out. Println (" 3, after "+ getResult (n [2], [3] n, n [4]));
}
Public static String getResult (int a, b int, int) c {
If (a==b & amp; & B==c) {
Return "the leopard";
{} else if (a==c)
Return "subsidiary";
} else if (a==b - 1 & amp; & B==1) {c
Return "shunza;"
} else if (a==b - 1 | |=b=c - 1) & amp; & A!!!!={
c)Return "half shun";
} else {
Return "miscellaneous six";
}
}
}
So just write in fact, there is half a pair and have a conflict situation, title didn't show, I also put it returned to the miscellaneous six
CodePudding user response: