A 10*10 matrix (which can be understood as a chessboard), generates a set of data at any time and fills in the Matrix. Numbers at any position are calculated except 4 and colored by the remainder, if the remainder is 0, the color is red, 1 is blue, 2 is green, and 3 is black. It can be understood that the color of 4 is generated and placed on the board, if one of the five stars with the same color is connected (The rule goes through wuziqi), find any group and output the position and bottom value of the five pawns.
Just implement it in the most stupid way:
Public class fivecolor {public void test () {int A [] [] = new int [10] [10]; for (INT I = 0; I <10; I ++) for (Int J = 0; j <10; j ++) A [I] [J] = (INT) (math. random () * 4); system. out. println ("initialization fill array:"); For (INT I = 0; I <10; I ++) {for (Int J = 0; j <10; j ++) system. out. print (A [I] [J] + ""); system. out. print ("\ n") ;}for (INT I = 0; I <10; I ++) for (Int J = 0; j <10; j ++) {If (J + 4 <10 & A [I] [J] = A [I] [J + 1] & A [I] [J] = [I] [J + 2] & A [I] [J] = A [I] [J + 3] & A [I] [J] = [I] [J + 4]) {system. out. println ("Horizontal five Sub:"); system. out. print ("[" + I + "] [" + J + "]"); system. out. print ("[" + I + "] [" + (J + 1) + "]"); system. out. print ("[" + I + "] [" + (J + 2) + "]"); system. out. print ("[" + I + "] [" + (J + 3) + "]"); system. out. print ("[" + I + "] [" + (J + 4) + "] \ n ");} if (I + 4 <10 & A [I] [J] = A [I + 1] [J] & A [I] [J] = [I + 2] [J] & A [I] [J] = A [I + 3] [J] & A [I + 4] [J] = A [I] [J]) {system. out. println ("vertical five Sub:"); system. out. print ("[" + I + "] [" + J + "]"); system. out. print ("[" + (I + 1) + "] [" + J + "]"); system. out. print ("[" + (I + 2) + "] [" + J + "]"); system. out. print ("[" + (I + 3) + "] [" + J + "]"); system. out. print ("[" + (I + 4) + "] [" + J + "] \ n ");} if (I-4>-1 & J + 4 <10 & A [I] [J] = A [I-1] [J + 1] & A [I] [j] = A [I-2] [J + 2] & A [I] [J] = A [I-3] [J + 3] & A [I-4] [J + 4] = A [I] [J]) {system. out. println ("oblique five Sub:"); system. out. print ("[" + I + "] [" + J + "]"); system. out. print ("[" + (I-1) + "] [" + (J + 1) + "]"); system. out. print ("[" + (I-2) + "] [" + (J + 2) + "]"); system. out. print ("[" + (I-3) + "] [" + (J + 3) + "]"); system. out. print ("[" + (I-4) + "] [" + (J + 4) + "] \ n ");} if (I + 4 <10 & J + 4 <10 & A [I] [J] = A [I + 1] [J + 1] & [i] [J] = A [I + 2] [J + 2] & A [I] [J] = A [I + 3] [J + 3] & A [I + 4] [J + 4] = A [I] [J]) {system. out. println ("Reversed five Sub:"); system. out. print ("[" + I + "] [" + J + "]"); system. out. print ("[" + (I + 1) + "] [" + (J + 1) + "]"); system. out. print ("[" + (I + 2) + "] [" + (J + 2) + "]"); system. out. print ("[" + (I + 3) + "] [" + (J + 3) + "]"); system. out. print ("[" + (I + 4) + "] [" + (J + 4) + "] \ n ");}}} public static void main (string [] ARGs) {fivecolor fc = new fivecolor (); FC. test ();}}
In December 2014, a 10*10 matrix (which can be understood as a chessboard) is used to generate a set of data input matrices at any time. The numbers at any position are calculated except 4, color by the remainder...