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...

Source: Internet
Author: User

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...

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.